该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public List findAll() {
List list = new ArrayList<>();
PreparedStatement stmt = null;
ResultSet rs = null;
try{
String sql = "select customer_id,customer_name,customer_account,sex,customer_password,email,phone,credits from customer order by customer_id desc";
stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery();
while(rs.next()){
int customerId = rs.getInt("customer_id");
String customerName = rs.getString("customer_name");
String customerAccount = rs.getString("customer_account");
String sex = rs.getString("sex");
String customerPassword = rs.getString("customer_password");
String email = rs.getString("email");
String phone = rs.getString("phone");
Double credits = rs.getDouble("credits");
list.add(new Customer(customerId,customerName,customerAccount,sex,customerPassword,email,phone,credits));
}
}catch(SQLException e){
e.printStackTrace();
throw new QXcmsException("查询客户信息失败");
}finally{
DBUtil.closeAll(null, stmt, rs);
}
return list;
}
然后怎么在就是测试类里面写获得这个新增的序列值,就是customerId.....大神写一句来助我,我是菜鸟~