1、描述问题
使用jdbc 连接数据库,这本来是十拿九稳的小题目,可是遇到一个从来没有遇到的问题while()循环怎么也进不去 rs.next()为false
public List<Dcustmsg> selectAll() {
Connection con=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try{
con=JdbcUtils.getConnection();
pstmt = con.prepareStatement("select id_no , phone_no from dCustMsg");
rs=pstmt.executeQuery();
List<Dcustmsg> list = new ArrayList<Dcustmsg>();
while(rs.next()){
//每次取出一行放入list
Dcustmsg dcustmsg = new Dcustmsg();
String id_no = rs.getString(1);
String phone_no = rs.getString(2);
dcustmsg.setId_no(id_no);
dcustmsg.setPhone_no(phone_no);
list.add(dcustmsg);
}
return list;
}catch(Exception e){
throw new RuntimeException(e);
}finally{
JdbcUtils.close(rs, pstmt, con);
}
}
在数