首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Clickhouse jdbc驱动程序连接问题

Clickhouse jdbc驱动程序连接问题
EN

Stack Overflow用户
提问于 2021-11-18 13:30:58
回答 1查看 495关注 0票数 1

我们正在尝试使用jdbc驱动程序连接到clickhouse服务器。我们的代码片段是用scala编写的,在java中并没有太大的不同。

代码语言:javascript
运行
复制
import java.util.Properties
Class.forName("ru.yandex.clickhouse.ClickHouseDriver")
    var conn : Connection = null
    try {
      conn = DriverManager.getConnection("jdbc:clickhouse://xxxxxx:9001/db_name", "usrname", "pass")
      val stmt = conn.createStatement()
      val sql =s"""select 1""".stripMargin
      stmt.executeQuery(sql)
    } finally {
      if(conn != null)
        conn.close()
    }

我们得到以下错误:

代码语言:javascript
运行
复制
ClickHouseUnknownException: ClickHouse exception, code: 1002, host: xxxxxxx, port: 9001; xxxxxxxxx:9001 failed to respond
Caused by: NoHttpResponseException: xxxxxxxxx:9001 failed to respond

我们浏览了其他几个页面,提到了同样的错误,为了与那里的建议保持一致,我们使用了最新版本的驱动程序(0.3.1-patch)。

我们也尝试了另一个驱动程序(clickhouse-native-jdbc),并得到了相同的错误。

为了添加更多上下文,我们尝试使用python clickhouse-driver和以下代码片段-

代码语言:javascript
运行
复制
from clickhouse_driver import Client

conn = Client('xxxxxxxxxx', password='pass', port=9001, user='usrname', verify= False, secure=True)
q1 ="select * from db_name.table limit 5"
result = conn.execute(q1)
print(result)

这是可行的。

我们不确定这是否仅仅是因为ssl安全设置为true,而verify设置为false。如果是这样,应该如何将这些添加到上面使用的驱动程序中?如果这不是原因,那是什么原因呢?

EN

Stack Overflow用户

回答已采纳

发布于 2021-11-20 07:59:31

正如@AndreiKoch在问题的评论中提到的,我们假设jdbc驱动程序将使用9001,就像python:https://clickhouse-driver.readthedocs.io/_/downloads/en/0.0.20/pdf/中使用的clickhouse驱动程序一样。

但是,原生jdbc驱动程序(在scala代码片段中使用)通过端口8123使用HTTP。

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70020750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档