Mybatis-plus-com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: #42000错误
使用mybatis-plus分页插件,分页查询时出现的错误
完整错误代码如下
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1ff8c245]
2022-11-15 12:22:22.766 ERROR 54688 --- [226-8002-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: #42000
### The error may exist in com/bravovax/filesystem/mapper/FileMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,file_id,file_name,file_type,file_size,file_url,service_id,service_type,is_use,is_delete,file_bucket_name FROM t_file LIMIT ? LIMIT ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: #42000
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: #42000] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: #42000
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
两个插件都会生效所以拼接了两个LIMIT,导致报错
删除一个,再次测试,通过。
下次遇到类似的错误先查看SQL语句是否正确,再分析原因