JDBC Driver
Connect to Hydrolix from a Java application using the ClickHouse JDBC driver. This page describes how to add the driver to your project, build the connection URL, and run a sample query.
If you want to use a graphical SQL client instead of writing Java code, see the DBeaver page, which uses the same underlying driver.
Prerequisites⚓︎
- Java 11 or later installed.
- A build tool (for example, Maven or Gradle), or the driver JAR on your classpath.
- Your Hydrolix cluster hostname and a bearer token for your account. To get a token, see Acquire authorization token.
Add the ClickHouse JDBC driver to your project⚓︎
Add the clickhouse-jdbc dependency to your build configuration. Check the ClickHouse JDBC releases for the latest version. The driver uses SLF4J for logging, so add an SLF4J binding too. The example uses slf4j-nop, which discards log messages; replace it with your project's preferred logging provider, for example Logback or Log4j 2.
Build the JDBC connection URL⚓︎
The JDBC URL uses the jdbc:ch scheme, followed by the https protocol, hostname, and port:
| JDBC URL Format | |
|---|---|
- Set
HDX_HOSTNAMEto your cluster's fully qualified hostname, for examplehostname.hydrolix.live. - Use the standard ClickHouse HTTP port
8088, or your cluster's configuredclickhouse_http_port. - Use the
httpsprotocol. Only usehttpif your cluster is configured to disable TLS.
Configure an authorization token in the bearer_token driver property. Load the token from an environment variable or secret manager so it doesn't appear in source code.
Open the connection and run a query⚓︎
The hydro.logs table contains log event data from the local cluster and is always present. This example opens a connection, runs a SELECT COUNT() against hydro.logs, and prints the result.
Run the example with your cluster hostname and bearer token in environment variables:
With Gradle, the run task requires the application plugin with mainClass = 'HydrolixJdbcExample' configured in your build.gradle.
| Example Output | |
|---|---|
Troubleshooting⚓︎
Connection refused or connection timeout⚓︎
The client can't reach the cluster on port 8088. Two different causes produce similar network-level errors, so check both:
- Client IP isn't on the cluster's allowlist. Verify that you've allowed inbound access to your cluster.
- Port 8088 isn't exposed on the cluster. By default, Hydrolix clusters run a ClickHouse HTTP server on port 8088, but the server doesn't run if the cluster configuration contains
disable_traefik_clickhouse_http_port: true. Check with your cluster administrator whether this tunable is set. If it'strue, the driver can't connect on port 8088 until the cluster exposes that port again.
SLF4J warns "No SLF4J providers were found"⚓︎
The driver logs through SLF4J and needs an SLF4J binding on the classpath. Add slf4j-nop (to discard log messages) or another binding like Logback or Log4j 2. The warning is non-fatal: queries still work.
See also⚓︎
- DBeaver for a graphical SQL client that uses the same JDBC driver.
- Tableau for connecting Tableau to Hydrolix through the ClickHouse JDBC connector.
- Splunk with DB Connect for connecting Splunk to Hydrolix using JDBC
- HTTP Query API for applications outside the JVM.
- Hydrolix Supports Mode Analytics - How to use Mode Analytics with Hydrolix through the ClickHouse JDBC driver