Updated on 2024-06-21 GMT+08:00

Setting Up a Connection

Function Description

During connection creation, the user and password configured in clickhouse-example.properties are used as authentication credentials. ClickHouse performs security authentication on the server with the user and password.

Sample Code

ClickHouseDataSource clickHouseDataSource =new ClickHouseDataSource(JDBC_PREFIX + serverList.get(tries - 1), clickHouseProperties);
connection = clickHouseDataSource.getConnection(user, password);

There will be huge security risks if the passwords used for authentication are directly written into the code. You are advised to store the password in ciphertext in the configuration file or environment variables and decrypt them when using them.