shizhengchao opened a new issue #7916: does druid-0.14 support PreparedStatement? URL: https://github.com/apache/incubator-druid/issues/7916 Does druid-0.14 support PreparedStatement with 'org.apache.calcite.avatica.remote.Driver' ? ### Affected Version 0.14 ### Description ```java String sql = "SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE __time BETWEEN TIMESTAMP ? AND TIMESTAMP ? GROUP BY page ORDER BY Edits DESC LIMIT 10"; String url = "jdbc:avatica:remote:url=http://10.204.57.143:8082/druid/v2/sql/avatica/"; Properties connectionProperties = new Properties(); try { try { Class.forName("org.apache.calcite.avatica.remote.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection connection = DriverManager.getConnection(url, connectionProperties); PreparedStatement ps = connection.prepareStatement(sql); ps.setString(1, "2015-09-12 00:00:00"); ps.setString(2, "2015-09-13 00:00:00"); final ResultSet rs = ps.executeQuery(TOPN_QUERY); while (rs.next()) { System.out.println(rs.getMetaData().getColumnName(1) + ":" + rs.getString(1)); System.out.println(rs.getMetaData().getColumnName(2) + ":" + rs.getInt(2)); } } catch (SQLException e) { e.printStackTrace(); } ``` Running the code gets the following error: ``` org.apache.calcite.avatica.AvaticaSqlException: Error -1 (00000) : while preparing SQL: SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE __time BETWEEN TIMESTAMP ? AND TIMESTAMP ? GROUP BY page ORDER BY Edits DESC LIMIT 10 at org.apache.calcite.avatica.Helper.createException(Helper.java:54) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:358) at org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:175) at com.fcbox.turbo.druid.avatica.SelectDemo.main(SelectDemo.java:25) java.lang.RuntimeException: org.apache.calcite.sql.parser.SqlParseException: Encountered "TIMESTAMP ?" at line 1, column 68. Was expecting one of: "SYMMETRIC" ... "ASYMMETRIC" ... "+" ... ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
