开发者社区> 问答> 正文

druid SQL合并配置报错?报错

@wenshao 你好,想跟你请教个问题:druid SQL合并配置报错,我配置了合并sql

<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
    <property name="mergeSql" value="true" />
</bean>

但是合并某些sql的时候报错了,报错信息:

[com.alibaba.druid.filter.stat.StatFilter] [ERROR] 2013-06-26 09:12:23 - ERROR  - merge sql error, dbType mysql, sql : 
SELECT COUNT(*) a FROM (select nickname,mobile,comment,createdate from ub_userdiscuss order by discuss_id desc) b  
com.alibaba.druid.sql.parser.ParserException: ERROR. token : COMMENT, pos : 54
at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:479)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:180)
at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:89)
at com.alibaba.druid.sql.parser.SQLSelectParser.expr(SQLSelectParser.java:411)
at com.alibaba.druid.sql.parser.SQLSelectParser.parseSelectList(SQLSelectParser.java:265)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:128)
at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59)
at com.alibaba.druid.sql.parser.SQLSelectParser.parseTableSource(SQLSelectParser.java:294)
at com.alibaba.druid.sql.parser.SQLSelectParser.parseFrom(SQLSelectParser.java:286)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:188)
at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseSelect(MySqlStatementParser.java:198)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:92)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:76)
at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:42)
at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)
at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:629)
at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305)
at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124)
at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:446)
at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:311)

还有:

[com.alibaba.druid.filter.stat.StatFilter] [ERROR] 2013-06-26 09:12:23 - ERROR  - merge sql error, dbType mysql, sql : 
select nickname,mobile,comment,createdate from ub_userdiscuss order by discuss_id desc limit ?  
com.alibaba.druid.sql.parser.ParserException: ERROR. token : COMMENT, pos : 30
at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:479)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:180)
at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:89)
at com.alibaba.druid.sql.parser.SQLSelectParser.expr(SQLSelectParser.java:411)
at com.alibaba.druid.sql.parser.SQLSelectParser.parseSelectList(SQLSelectParser.java:265)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:128)
at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseSelect(MySqlStatementParser.java:198)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:92)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:76)
at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:42)
at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)
at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:629)
at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305)
at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124)
at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:446)
at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:311)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)


druid版本:druid-0.2.21

展开
收起
爱吃鱼的程序员 2020-06-22 18:44:35 1178 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    噢,comment是关键字。。。,这个问题下个版本解决

    引用来自“wenshao”的答案

    噢,comment是关键字。。。,这个问题下个版本解决

    问题已经修复,你验证一下:

    http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/0.2.22-SNAPSHOT/

    2020-06-22 18:44:51
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SQL Server 2017 立即下载
GeoMesa on Spark SQL 立即下载
原生SQL on Hadoop引擎- Apache HAWQ 2.x最新技术解密malili 立即下载