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;}
2 回答
慕运维8079593
TA贡献1876条经验 获得超5个赞
如果我没看错的话应该是sql语法错了 limit后边是不应该有括号的 应该是这样
select * from table limit 0,100
一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
String sql = " select id,title,author,content from note limit (" + ((currentPage-1)*lineSize) + "," + lineSize + ")" ;
是 SQL语句吗? 是不是你写错了。
添加回答
举报
0/150
提交
取消