What is "HikariCP"?

光 HikariCP・A solid, high-performance, JDBC connection pool at last. in short, it's library for JDBC connection pool, it make you easier manage your  JDBC connection pool.

Using HikariCP integrate Clickhouse, there are three steps.

  1. config Clickhouse datasource url/username/password on the yml file, it also set this information on Vault, it depends on you.
  2. create the config class on SpringBoot, this class will read Clickhouse configuration on yml file, and establish connection.
  3. this step is optional, create JdbcTemplate, it is easy for query clickhouse

First step

config yml file

    clickhouse:type: com.zaxxer.hikari.HikariDataSource
    driver-class-name: com.clickhouse.jdbc.ClickHouseDriver
    jdbc-url: jdbc:clickhouse://xxxxx
    username: abc
    password: abc

Second step

create config class

class ClickHouseDataSourceConfig {
    @ConfigurationProperties(prefix = "spring.datasource.clickhouse")
    fun clickhouseDataSource(
            @Value("${spring.datasource.clickhouse.username}") username: String,
            @Value("${spring.datasource.clickhouse.password}") password: String
    ): DataSource = DataSourceBuilder.create().type(HikariDataSource::class.java).build().apply {
        this.username = username
        this.password = password
        this.isReadOnly = true
    @Bean("clickhouseJdbcTemplate") //create JdbcTemplate,optional
    fun clickhouseJdbcTemplate(@Qualifier("clickhouseDataSource") dataSource: DataSource): JdbcTemplate =

that's all