Skip to content

Jdbc support error #400

Closed
Closed
@zhegexiaohuozi

Description

@zhegexiaohuozi

@allwefantasy I excute the sql SELECT user_id,sum(amt) as sum_amt from index1/type2 GROUP BY user_id HAVING sum_amt < 500 ORDER BY uid desc limit 100,5,and found that the condition HAVING sum_amt < 500(or sum(amt) < 500) did not produce any results. Also the condition limit 100,5 did not produce any results.
If excute the following sql SELECT * FROM (SELECT user_id,sum(amt) as sum_amt from index1/type2 GROUP BY user_id) as a WHERE a.sum_amt < 500 ORDER BY a.uid desc limit 100,5

And I get the Exception:

Exception in thread "main" java.sql.SQLException: Error
	at com.alibaba.druid.pool.ElasticSearchDruidDataSource.handleConnectionException(ElasticSearchDruidDataSource.java:1109)
	at com.alibaba.druid.pool.DruidPooledConnection.handleException(DruidPooledConnection.java:127)
	at com.alibaba.druid.pool.DruidPooledStatement.checkException(DruidPooledStatement.java:68)
	at com.alibaba.druid.pool.ElasticSearchDruidPooledPreparedStatement.executeQuery(ElasticSearchDruidPooledPreparedStatement.java:61)
	at com.xx.test.test.Elastic.jdbc(Elastic.java:79)
	at com.xx.test.test.Elastic.main(Elastic.java:94)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassCastException: com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource
	at org.nlpcn.es4sql.parse.SqlParser.findFrom(SqlParser.java:227)
	at org.nlpcn.es4sql.parse.SqlParser.parseSelect(SqlParser.java:48)
	at org.nlpcn.es4sql.parse.SqlParser.parseSelect(SqlParser.java:35)
	at org.nlpcn.es4sql.query.ESActionFactory.create(ESActionFactory.java:61)
	at org.nlpcn.es4sql.SearchDao.explain(SearchDao.java:46)
	at com.alibaba.druid.pool.ElasticSearchDruidPooledPreparedStatement.getObjectResult(ElasticSearchDruidPooledPreparedStatement.java:72)
	at com.alibaba.druid.pool.ElasticSearchDruidPooledPreparedStatement.executeQuery(ElasticSearchDruidPooledPreparedStatement.java:46)
	... 7 more

druid version

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.16</version>
        </dependency>

If use higher version than 1.0.16 ,will get exception

Exception in thread "main" java.lang.NoSuchMethodError: com.alibaba.druid.pool.DruidConnectionHolder.<init>(Lcom/alibaba/druid/pool/DruidAbstractDataSource;Ljava/sql/Connection;)V
	at com.alibaba.druid.pool.ElasticSearchDruidDataSource.init(ElasticSearchDruidDataSource.java:571)
	at com.alibaba.druid.pool.ElasticSearchDruidDataSource.getConnection(ElasticSearchDruidDataSource.java:897)
	at com.alibaba.druid.pool.ElasticSearchDruidDataSource.getConnection(ElasticSearchDruidDataSource.java:893)
	at com.xx.test.test.Elastic.jdbc(Elastic.java:77)
	at com.xx.test.test.Elastic.main(Elastic.java:95)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

thx!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions