public List queryAll(int currentPage, int lineSize) throws Exception {
List<Note> all = new ArrayList<Note>() ;
String sql = " select id,title,author,content from note limit (" + ((currentPage-1)*lineSize) + "," + lineSize + ")" ;
PreparedStatement pstmt = null ;
try {
pstmt = this.dbc.getConnection().prepareStatement(sql) ; // 每次执行到这里就会直接finally了。请问这是为什么
ResultSet rSet = pstmt.executeQuery() ;
while(rSet.next()){
Note note = new Note() ;
note.setId(rSet.getInt(1)) ;
note.setTitle(rSet.getString(2)) ;
note.setAuthor(rSet.getString(3)) ;
note.setContent(rSet.getString(4)) ;
all.add(note) ;
}
rSet.close() ;
pstmt.close() ;
} catch (Exception e) {
// TODO: handle exception
}
finally{
dbc.close() ;
}
return all;
}
慕运维8079593
一只萌萌小番薯
相关分类