---
sidebar_position: 1
title: JDBC driver
description: Connect to MotherDuck from Java applications using the official DuckDB JDBC driver.
---

import CodeBlock from '@theme/CodeBlock';
import appVersions from '@site/src/appVersions.json';

The official [DuckDB JDBC driver](https://duckdb.org/docs/api/java.html) supports MotherDuck out of the box!

To connect, you need a dependency on the driver. For example, in your Maven pom.xml file:

<CodeBlock language="xml">
{`<dependency>
    <groupId>org.duckdb</groupId>
    <artifactId>duckdb_jdbc</artifactId>
    <version>${appVersions.duckdb_jdbc}</version>
</dependency>`}
</CodeBlock>

Your code can then create a `Connection` by using `jdbc:duckdb:md:databaseName` connection string format:

```xml
Connection conn = DriverManager.getConnection("jdbc:duckdb:md:my_db");
```

This `Connection` can then be [used directly](https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Connection.html) or through any framework built on `java.sql` JDBC abstractions.

There are two main ways to programmatically authenticate with a valid MotherDuck token:

1) Passing it in through the connection configuration

```java
    Properties config = new Properties();
    config.setProperty("motherduck_token", token);
    Connection mdConn = DriverManager.getConnection("jdbc:duckdb:md:mdw", config);
```

2) Passing the token as a connection string parameter:

```java
Connection conn = DriverManager.getConnection("jdbc:duckdb:md:my_db?motherduck_token="+token);
```

See [Authenticating to MotherDuck](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/authenticating-to-motherduck.md) for more details.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/integrations/language-apis-and-drivers/jdbc-driver/",
  "page_title": "JDBC driver",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
