java.sql.SQLException: Undeclared variable: 0 Query: SELECT * FROM stu LIMIT ? OFFSET ? Parameters: [5, 0]
public List<Student> findStudentByPage(int currentPage) throws SQLException {
System.out.println("資料庫收到的="+currentPage);
QueryRunner runner = new QueryRunner(JDBCUtil.getDataSource());
// limt ? 回傳多少條資料 offset ?跳過多少條資料
// 5 0 第一頁(i-1)5
// 5 5 第二頁
// 10 5
return runner.query("SELECT * FROM stu LIMIT ? OFFSET ? ",
new BeanListHandler<Student>(Student.class),PAGE_SIZE,(currentPage-1)*PAGE_SIZE);
uj5u.com熱心網友回復:
把OFFSET 改成,試試看。SELECT * FROM stu LIMIT ? ,?
uj5u.com熱心網友回復:
SELECT * FROM stu LIMIT 10 OFFSET 20 ;改成
SELECT * FROM stu LIMIT 20,10 ;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/66837.html
標籤:MySQL
上一篇:請教
下一篇:mongodb資料庫安全問題
