Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Using JDBC requires the ClickHouse JDBC bridge, so you will need to use
clickhouse-local on a local machine to stream the data from your database to ClickHouse Cloud. Visit the Using clickhouse-local page in the Migrate section of the docs for details.Install the ClickHouse JDBC Bridge locally
The easiest way to use the ClickHouse JDBC Bridge is to install and run it on the same host where also ClickHouse is running: Let’s start by connecting to the Unix shell on the machine where ClickHouse is running and create a local folder where we will later install the ClickHouse JDBC Bridge into (feel free to name the folder anything you like and put it anywhere you like):~/clickhouse-jdbc-bridge/config/datasources/mysql8.json:
in the config file above
- you’re free to use any name you like for the datasource, we used
mysql8 - in the value for the
jdbcUrlyou need to replace<host>, and<port>with appropriate values according to your running MySQL instance, e.g."jdbc:mysql://localhost:3306" - you need to replace
<username>and<password>with your MySQL credentials, if you don’t use a password, you can delete the"password": "<password>"line in the config file above - in the value for
driverUrlswe just specified a URL from which the current version of the MySQL JDBC driver can be downloaded. That’s all we have to do, and the ClickHouse JDBC Bridge will automatically download that JDBC driver (into a OS specific directory).
Now we’re ready to start the ClickHouse JDBC Bridge:
We started the ClickHouse JDBC Bridge in foreground mode. In order to stop the Bridge you can bring the Unix shell window from above in foreground and press
CTRL+C.Use the JDBC connection from within ClickHouse
ClickHouse can now access MySQL data by either using the jdbc table function or the JDBC table engine. The easiest way to execute the following examples is to copy and paste them into theclickhouse-client or into the Play UI.
- jdbc Table Function:
As the first parameter for the jdbc table function we’re using the name of the named data source that we configured above.
- JDBC Table Engine:
As the first parameter for the jdbc engine clause we’re using the name of the named data source that we configured aboveThe schema of the ClickHouse JDBC engine table and schema of the connected MySQL table must be aligned, e.g. the column names and order must be the same, and the column data types must be compatible
Install the ClickHouse JDBC Bridge externally
For a distributed ClickHouse cluster (a cluster with more than one ClickHouse host) it makes sense to install and run the ClickHouse JDBC Bridge externally on its own host: This has the advantage that each ClickHouse host can access the JDBC Bridge. Otherwise the JDBC Bridge would need to be installed locally for each ClickHouse instance that is supposed to access external data sources via the Bridge. In order to install the ClickHouse JDBC Bridge externally, we do the following steps:- We install, configure and run the ClickHouse JDBC Bridge on a dedicated host by following the steps described in section 1 of this guide.
- On each ClickHouse Host we add the following configuration block to the ClickHouse server configuration (depending on your chosen configuration format, use either the XML or YAML version):
- XML
- YAML
- you need to replace
JDBC-Bridge-Hostwith the hostname or ip address of the dedicated ClickHouse JDBC Bridge host - we specified the default ClickHouse JDBC Bridge port
9019, if you’re using a different port for the JDBC Bridge then you must adapt the configuration above accordingly