【问题标题】:Adding client tags to presto jdbc connection将客户端标签添加到 presto jdbc 连接
【发布时间】:2020-05-29 03:40:27
【问题描述】:

我正在使用 jdbc 连接到 presto 服务器。

从文档中,我能够连接到服务器并运行查询。 https://prestodb.io/docs/current/installation/jdbc.html

我在连接/语句中发送 ClientTag (X-Presto-Client-Tags) 时遇到问题。

这是建立连接和运行查询的函数。

public void test() {
    java.util.Properties info = new java.util.Properties();

    if (PRESTO_USER != null) {
        info.put("user", PRESTO_USER);
    }
    if (PRESTO_PASSWORD != null) {
        info.put("password", PRESTO_PASSWORD);
    }
        info.put("ClientTags", "my,tag");



    try (Connection connection = DriverManager.getConnection(PRESTO_URL, info);
         Statement statement = connection.createStatement()) {
        testBody(connection, statement);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Exception occured");
    }
}

但是,它失败了

java.sql.SQLException: Unrecognized connection property 'ClientTags'
    at com.facebook.presto.jdbc.PrestoDriverUri.validateConnectionProperties(PrestoDriverUri.java:316)

对于 pyhive,我能够覆盖会话并传递客户端标签 https://github.com/dropbox/PyHive/issues/283。 jdbc驱动也可以这样吗?

【问题讨论】:

    标签: presto presto-jdbc


    【解决方案1】:

    目前无法在连接 URL 上设置 ClientTags。 请创建功能请求@https://github.com/trinodb/trino/issues/

    目前唯一的办法就是使用Connection方法:

    Connection connection = DriverManager.getConnection("....");
    connection.unwrap(PrestoConnection.class)
      .setClientInfo("ClientTags", "one,two,three");
    

    【讨论】:

      猜你喜欢
      • 2017-10-17
      • 2016-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-10
      • 2015-08-22
      • 2016-03-01
      相关资源
      最近更新 更多