【发布时间】:2017-02-25 10:40:04
【问题描述】:
我有一个返回类型是客户的方法,它是一个 pojo。当我从数据库中获得所需的customerId 时,我想返回带有customerId 对应数据的客户对象。这意味着它有客户姓名、地址等。如何处理?
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还是需要先找到?