分页查询,同时返回总记录数时使用如下查询:
select SQL_CALC_FOUND_ROWS * from user limit 0,10;
SELECT FOUND_ROWS() as count;
出现报错信息,且报错信息是第二个语句。
### The error may involve defaultParameterMap
### The error occurred while setting parameters
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT FOUND_ROWS() as dataCount' at line 8
解决方法:
在jdbc配置的url里面添加noAccessToProcedureBodies=true&allowMultiQueries=true参数
url=jdbc:mysql://localhost:3306/dbName?useUnicode=true&characterEncoding=utf8mb4;noAccessToProcedureBodies=true&allowMultiQueries=true