List<Book> list = new ArrayList<Book>();
Connection con = DBConnection.getCon();
//String sql = "select top ? * from bookInformation where id not in (select top ? id from bookInformation)";
//String sql = "select top 9 * from bookInformation ";
String sql = "select top + Book.PAGE_SIZE from bookInformation where id not in (select top (page-1)*Book.PAGE_SIZE id from bookInformation)";
try{
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setInt(1,Book.PAGE_SIZE); //設置查詢數據所返回的記錄數
stmt.setInt(2,(page-1)*Book.PAGE_SIZE); //設置查詢記錄的開始位置
ResultSet rst = stmt.executeQuery();
上面是代碼,出現了索引超出范圍的錯誤。請大家幫我解決一下?非常感謝
String sql = "select top + Book.PAGE_SIZE from bookInformation where id not in (select top (page-1)*Book.PAGE_SIZE id from bookInformation)";
->
String sql = "select top " + Book.PAGE_SIZE + " from bookInformation where id not in (select top " + (page-1)*Book.PAGE_SIZE + " id from bookInformation)";
stmt.setInt(1,Book.PAGE_SIZE); //設置查詢數據所返回的記錄數
stmt.setInt(2,(page-1)*Book.PAGE_SIZE); //設置查詢記錄的開始位置
刪除