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

Add example with Hikari

Open mshustov opened this issue 1 year ago • 5 comments

add an example of usage with Hikari

mshustov avatar Oct 31 '23 09:10 mshustov

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

mshustov avatar Oct 31 '23 11:10 mshustov

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.

Young0516 avatar Nov 01 '23 06:11 Young0516

@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.

mzitnik avatar Nov 07 '23 07:11 mzitnik

@mzitnik thanks

Young0516 avatar Nov 07 '23 09:11 Young0516

@mzitnik let's add it to the docs

mshustov avatar Jan 08 '24 17:01 mshustov