Tip
If you already have a ClickHouse instance running, skip the steps to set up and clean up ClickHouse.
-
Start a ClickHouse instance:
docker run -d --rm --name some-clickhouse-server -p 8123:8123 -e CLICKHOUSE_USER=user -e CLICKHOUSE_PASSWORD=pass clickhouse/clickhouse-server
-
Install the ClickHouse ADBC driver:
dbc install clickhouse
-
Customize the
mainmethod inExample.java- Change the connection arguments in the
params.put()calls- Format
uriaccording to the ClickHouse HTTP interface, or keep it as is
- Format
- If you changed which database you're connecting to, also change the SQL SELECT statement in
stmt.setSqlQuery()
- Change the connection arguments in the
-
Run the Java program:
mvn compile exec:exec
Stop the Docker container running ClickHouse:
docker stop some-clickhouse-server