达梦数据库配合Druid报错及解决方案
编写代码进行测试的时候,控制台报出如下错误
2021-02-26 16:34:49.637 ERROR 21256 --- [nio-8080-exec-1] c.alibaba.druid.filter.stat.StatFilter : merge sql error, dbType dm, sql : SELECT ... ASC LIMIT ?
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :' ASC LIMIT ? ',expect IDENTIFIER, actual IDENTIFIER LIMIT
at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:280) ~[druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:375) ~[druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:76) ~[druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:43) ~[druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:146) [druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:634) [druid-1.1.0.jar:1.1.0]
at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:310) [druid-1.1.0.jar:1.1.0]
原因是因为 druid
的 merge
功能不支持达梦的 asc LIMIT ?
分页排序写法
properties
#springboot
spring.datasource.druid.filter.stat.merge-sql=false
yml
#springboot
spring:
datasource:
druid:
filter:
stat:
merge-sql:false