while(rs.next()){ User user = new User(); user.setUsername(rs.getString("e_username")); user.setPassword(rs.getString("e_password")); user.setName(rs.getString("e_name")); user.setAge(rs.getInt("e_age")); user.setSex(rs.getInt("e_sex")); Date d = stringToDate(rs.getString("e_birthdate"), dateFormat); user.setBirthdate(d); user.setPhone(rs.getString("e_phone")); user.setE_mail(rs.getString("e_mail")); list.add(user);
while(rs.next()){ User user = new User();//这一句放在循环外边就会是最后一条数据,如果放在循环里边,应该是不可能是最后一条数据,楼主自己再检查一下吧.在循环加一个System.out.println(rs.getString("e_username"));试试有什么结果,先检查看是读取的时候错了,还是在循环显示的时候错了. user.setUsername(rs.getString("e_username")); user.setPassword(rs.getString("e_password")); user.setName(rs.getString("e_name")); user.setAge(rs.getInt("e_age")); user.setSex(rs.getInt("e_sex")); Date d = stringToDate(rs.getString("e_birthdate"), dateFormat); user.setBirthdate(d); user.setPhone(rs.getString("e_phone")); user.setE_mail(rs.getString("e_mail")); list.add(user);