Home > database >  Three days didn't understand Java. SQL. SQLException: Undeclared variable: 0 Query:
Three days didn't understand Java. SQL. SQLException: Undeclared variable: 0 Query:

Time:09-23

Java. SQL. SQLException: Undeclared variable: 0 Query: SELECT * FROM stu LIMIT? OFFSET? The Parameters: [5, 0]


Public List FindStudentByPage (int currentPage) throws SQLException {
System. The out. Println (" database received="+ currentPage);
QueryRunner runner=new QueryRunner (JDBCUtil getDataSource ());
//limt? How return data offset? Skip the article how much data
//5 0 the first page (I - 1)
//5 5 page 2
//10 5
Return runner. The query (" SELECT * FROM stu LIMIT? OFFSET? "
New BeanListHandler (Student class), PAGE_SIZE, (currentPage - 1) * PAGE_SIZE);

CodePudding user response:

Change the OFFSET to, give it a try,
SELECT * FROM stu LIMIT? ,?

CodePudding user response:

SELECT * FROM stu LIMIT 10 OFFSET 20;
Change
SELECT * FROM stu LIMIT 20, 10;
  • Related