我有一种方法,其返回类型是customer,它是pojo。当我从数据库中获得要求customerId
时,我想要返回客户对象与相应的数据customerId
。这意味着它有客户名称,地址等。如何继续?从数据库中获取数据并以pojo对象的形式返回
public class Customer verifyCustomerId(cutomerId){
statement = connection.createStatement();
resultSet = statement.executeQuery("select customerid from customer");
while (resultSet.next()) {
if (cutomerId == resultSet.getInt(1)) {
// return data corresponding to this id in the form of object of pojo customer
}
}
return null;
}
您是否在此逻辑开始时有customerId,还是您需要先找到它? – JamesB