我们正在尝试使用jdbc驱动程序连接到clickhouse服务器。我们的代码片段是用scala编写的,在java中并没有太大的不同。
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()
}
我们得到以下错误:
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和以下代码片段-
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。如果是这样,应该如何将这些添加到上面使用的驱动程序中?如果这不是原因,那是什么原因呢?
发布于 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。
https://stackoverflow.com/questions/70020750
复制相似问题