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) ; // 每次執(zhí)行到這里就會(huì)直接finally了。請(qǐng)問(wèn)這是為什么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;}
請(qǐng)問(wèn)下在java中執(zhí)行sql語(yǔ)句,為什么每次讀到limit就會(huì)直接跳過(guò)?
紫衣仙女
2022-04-03 12:09:39
