想把stu中的值存到list中,调试到这一步再向下调试直接跳过了list.add(stu);最后return list;的返回值也是空的
请问一下这是怎么回事?
public List<Student> findStudents(String studName, Integer pageNo, Integer pageSize){
List<Student> list=new ArrayList<Student>();
try{
conn=SqlHelper.connect();
String sql="Select a.major_name,b.* from xsgl_major a,xsgl_student b where a.major_id=b.major_id and stud_name like ? ";
sql=sql+ " limit "+ (pageNo-1)* pageSize+","+pageSize;
ps=conn.prepareStatement(sql);
ps.setString(1, "%"+studName+"%");
rs=ps.executeQuery();
while(rs.next()){
Student stu=new Student();
Major major=new Major();
stu.setMajor(major);
major.setMajorName(rs.getString(1));
stu.setStudNo(rs.getString(2));
major.setMajorId(rs.getInt(3));
stu.setStudName(rs.getString(4));
stu.setStudSex(rs.getString(5));
stu.setStudBirthDate(rs.getDate(6));
stu.setStudIsMember(rs.getBoolean(7));
stu.setStudAddress(rs.getString(8));
stu.setStudResume(rs.getString(9));
stu.setStudPic(rs.getBytes(10));
list.add(stu);
}
}catch(Exception e){
}finally{
SqlHelper.closeResultSet(rs);
SqlHelper.closePreparedStatement(ps);
SqlHelper.closeConnection(conn);
}
return list;
}