|
| 1 | +--- |
| 2 | +title: Connecting to Databend with JDBC |
| 3 | +sidebar_label: Connect with JDBC |
| 4 | +description: |
| 5 | + Connecting to Databend with JDBC |
| 6 | +--- |
| 7 | + |
| 8 | +Databend provides a JDBC driver that enables connection to Databend from a client application, such as [DBeaver](https://dbeaver.com/). DBeaver comes with numerous pre-configured drivers for SQL, NoSQL, key-value databases, graph databases, search engines, and more. However, the Databend JDBC driver is not currently pre-configured in DBeaver, which means that you cannot locate and select Databend while creating a connection in the application. Nevertheless, you can manually add the driver to DBeaver, allowing you to establish a connection to Databend in the same way you would with a pre-configured database. |
| 9 | + |
| 10 | +The following shows how to add the Datebend JDBC driver to a client application and connect to Databend via the driver, using DBeaver as an example. For more information about the driver, refer to https://github.com/databendcloud/databend-jdbc |
| 11 | + |
| 12 | +## Example: Connect from DBeaver with JDBC |
| 13 | + |
| 14 | +To connect to Databend from DBeaver with the Databend JDBC driver, you need to add the driver to DBeaver's Driver Manager first, and then select the driver when you create a connection. |
| 15 | + |
| 16 | +### Step 1. Add Databend JDBC Driver to DBeaver |
| 17 | + |
| 18 | +1. In DBeaver, select **Database** > **Driver Manager** to open the Driver Manager, then click **New** to create a new driver. |
| 19 | + |
| 20 | +2. On the **Settings** tab, enter the required information for the new driver as follows: |
| 21 | + |
| 22 | + - **Driver**: databend |
| 23 | + - **Driver Type**: Generic |
| 24 | + - **Class Name**: com.databend.jdbc.DatabendDriver |
| 25 | + - **URL Template**: jdbc:databend://{user}:{password}@{host}:{port}/{database} |
| 26 | + - **Default Port**: 8000 |
| 27 | + - **Default User**: root |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +3. On the **Libraries** tab, click **Add Artifact**, then copy and paste the following to the **Dependency Declaration** textbox: |
| 32 | + |
| 33 | +```java |
| 34 | +<dependency> |
| 35 | + <groupId>com.databend</groupId> |
| 36 | + <artifactId>databend-jdbc</artifactId> |
| 37 | + <version>0.0.6</version> |
| 38 | +</dependency> |
| 39 | +``` |
| 40 | + |
| 41 | +4. Click **OK** to close the windows. |
| 42 | + |
| 43 | +### Step 2. Create a Connection with Databend JDBC Driver |
| 44 | + |
| 45 | +1. In DBeaver, search for and select `databend` on **Database** > **New Database Connection** first, and then click **Next**. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +2. Set your connection settings. The default settings can connect to a local instance of Databend. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +3. Click **Test Connection** to check if the connection is successful. |
0 commit comments