【问题标题】:Error while connecting to druid using SQL interface使用 SQL 接口连接到 druid 时出错
【发布时间】:2018-07-10 23:26:34
【问题描述】:

我正在尝试使用 avatica jar 连接到 druid 数据库 以下是代码。

String url = "jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica";
Properties connectionProperties = new Properties();

try (Connection connection = DriverManager.getConnection(url, connectionProperties))
{
    try (
            final Statement statement = connection.createStatement();
            final ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) as rowcount FROM  wikiticker"))
    {
        while (resultSet.next())
        {
            int count = resultSet.getInt("rowcount");
            System.out.println("Total records:" + count);
        }
        resultSet.close();
    }
}
catch (SQLException e)
{
    e.printStackTrace();
}

我得到以下异常,有人可以告诉我出了什么问题吗?我已将运行时属性设置为启用 sql。

Exception in thread "main" java.lang.RuntimeException: Failed to execute HTTP Request, got HTTP/404
        at org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl.send(AvaticaCommonsHttpClientImpl.java:138)
        at org.apache.calcite.avatica.remote.RemoteService.apply(RemoteService.java:34)
        at org.apache.calcite.avatica.remote.JsonService.apply(JsonService.java:172)
        at org.apache.calcite.avatica.remote.Driver.connect(Driver.java:175)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:208)
        at com.test.druid.sql.Main.main(Main.java:17)

【问题讨论】:

    标签: druid apache-calcite


    【解决方案1】:

    看起来您的代理实例在启动时缺少-Ddruid.sql.enabled=true 标志。详情可参考http://druid.io/docs/latest/querying/sql.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多