clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

JDBC Driver and Docker Container

Open dbschema-pro opened this issue 3 years ago • 3 comments

I tried to start a ClickHouse docker container:

docker run -d --name clickhouse --ulimit nofile=262144:262144 -p 8123:8123 -p 9000:9000 -p 443:443 yandex/clickhouse-server

And connect using JDBC Driver using:

jdbc:ch:https://localhost:443
Class: com.clickhouse.jdbc.ClickHouseDriver

I receive

java.sql.SQLException: SSL peer shut down incorrectly, server ClickHouseNode [uri=https://localhost:443/default, options={sslmode=STRICT}]
  at com.clickhouse.jdbc.SqlExceptionUtils.handle(SqlExceptionUtils.java:55)
  at com.clickhouse.jdbc.SqlExceptionUtils.handle(SqlExceptionUtils.java:70)
  at com.clickhouse.jdbc.internal.ClickHouseConnectionImpl.getServerInfo(ClickHouseConnectionImpl.java:86)
  at com.clickhouse.jdbc.internal.ClickHouseConnectionImpl.<init>(ClickHouseConnectionImpl.java:244)
  at com.clickhouse.jdbc.internal.ClickHouseConnectionImpl.<init>(ClickHouseConnectionImpl.java:214)
  at com.clickhouse.jdbc.ClickHouseDriver.connect(ClickHouseDriver.java:145)
  at com.clickhouse.jdbc.ClickHouseDriver.connect(ClickHouseDriver.java:41)

What can be wrong? Is any default user or password which I should use, or should I change the docker config?

dbschema-pro avatar Jul 21 '22 12:07 dbschema-pro

Hi @wise-coders, are you using self-signed certificates? Did you try to change sslmode to none or provide root CA?

The error looks like ssl handshake error mentioned at here.

zhicwu avatar Jul 21 '22 14:07 zhicwu

I succeed using port 8123, and ?ssl=false&sslmode=NONE This with the port was confusing for me. Either the docker container uses a non-standard value, or the documentation should be improved. Is better to use a single value all over, including the containers.

dbschema-pro avatar Jul 21 '22 14:07 dbschema-pro

I see. By default, ClickHouse uses port 8123 for http and 8443 for https. This can be changed in server configuration like this.

When you use JDBC driver, you don't have to always specify port number in connection string. For example: jdbc:ch:http://localhost is same as jdbc:clickhouse:http://localhost:8123 and jdbc:ch:https://localhost is same as jdbc:clickhouse:http://localhost:8443?ssl=true&sslmode=strict.

zhicwu avatar Jul 21 '22 15:07 zhicwu