ClickHouse / clickhouse-java

ClickHouse Java Clients & JDBC Driver
https://clickhouse.com
Apache License 2.0
1.45k stars 537 forks source link

Add example with Hikari #1480

Open mshustov opened 1 year ago

mshustov commented 1 year ago

add an example of usage with Hikari

mshustov commented 1 year ago

from @mzitnik https://github.com/ClickHouse/ClickHouse/discussions/56127#discussioncomment-7433272

In JDBC driver .getConnection is generating an under the hood a single connection to the DB the heavy lifting of the connection pool is done outside the diver, by using. Hikari externally solves the concurrency issue.

HikariConfig configuration = new HikariConfig();
configuration.setMaximumPoolSize(1);
configuration.setJdbcUrl("jdbc:ch:{hostname}:{port}/default?insert_quorum=auto&server_time_zone&server_version=22.13.1.24495");
configuration.setUsername(username);
configuration.setPassword(password);
configuration.setValidationTimeout(6000000);
HikariDataSource ds = new HikariDataSource(configuration); 

Use Connection conn = ds.getConnection(); to get connection and you get it from hikari pool I will provide a sample with full mvn example for using

Young0516 commented 1 year ago

hi @mzitnik and @mshustov thanks for your response. by the way, I can integrate hikari by myself. but , I also hope the community can provide a best practice example.

mzitnik commented 1 year ago

@mshustov Checked the code today and found an example how to use it just making sure that we want it in the ClickHouse docs is it correct.

@Young0516 is the example above is good enough.

Young0516 commented 1 year ago

@mzitnik thanks

mshustov commented 11 months ago

@mzitnik let's add it to the docs