> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/module-development/capabilities/jdbc-drivers.md).

# JDBC Drivers

Register JDBC database drivers in your BoxLang module (Java only)

{% hint style="warning" %}
JDBC drivers require **Java**. There is no BoxLang-only mechanism for registering database drivers.
{% endhint %}

JDBC driver modules provide database connectivity for BoxLang's datasource system. Common examples include `bx-mysql`, `bx-postgresql`, and `bx-sqlite`.

## Registration Methods

There are two approaches to register JDBC drivers:

{% tabs %}
{% tab title="Standard java.sql.Driver" %}
Implement `java.sql.Driver` and register via `DriverManager`:

**File:** `src/main/java/ortus/boxlang/modules/mymodule/jdbc/MyJDBCDriver.java`

```java
import java.sql.*;

public class MyJDBCDriver implements Driver {

    static {
        try {
            DriverManager.registerDriver( new MyJDBCDriver() );
        } catch ( SQLException e ) {
            throw new RuntimeException( "Failed to register driver", e );
        }
    }

    @Override
    public Connection connect( String url, Properties info ) {
        // Return connection if URL matches
    }

    @Override
    public boolean acceptsURL( String url ) {
        return url.startsWith( "jdbc:mydb:" );
    }

    // ... other Driver methods
}
```

**ServiceLoader Config:** `META-INF/services/java.sql.Driver`

```
ortus.boxlang.modules.mymodule.jdbc.MyJDBCDriver
```

{% endtab %}

{% tab title="BoxLang IJDBCDriver" %}
Implement `IJDBCDriver` for BoxLang-specific features:

```java
import ortus.boxlang.runtime.jdbc.IJDBCDriver;

public class MyBoxLangJDBCDriver implements IJDBCDriver {

    @Override
    public String getPrefix() {
        return "jdbc:mydb:";
    }

    @Override
    public Connection connect( String url, Properties info ) {
        // Return connection
    }

    @Override
    public boolean acceptsURL( String url ) {
        return url.startsWith( getPrefix() );
    }
}
```

{% endtab %}
{% endtabs %}

## Module Structure

JDBC driver modules are typically simple — just the driver JAR and registration:

```
bx-mydb/
├── box.json
├── ModuleConfig.bx
├── libs/
│   └── mydb-jdbc.jar
└── src/main/java/
    └── ortus/boxlang/modules/mydb/
        └── MyDBDriver.java
```

## Open Source JDBC Modules

Reference these existing JDBC driver modules:

| Module                                                          | Database      |
| --------------------------------------------------------------- | ------------- |
| [bx-mysql](https://github.com/ortus-boxlang/bx-mysql)           | MySQL/MariaDB |
| [bx-postgresql](https://github.com/ortus-boxlang/bx-postgresql) | PostgreSQL    |
| [bx-mssql](https://github.com/ortus-boxlang/bx-mssql)           | SQL Server    |
| [bx-oracle](https://github.com/ortus-boxlang/bx-oracle)         | Oracle        |
| [bx-sqlite](https://github.com/ortus-boxlang/bx-sqlite)         | SQLite        |
| [bx-derby](https://github.com/ortus-boxlang/bx-derby)           | Apache Derby  |

## Next Steps

* [Services](/boxlang-framework/module-development/capabilities/services.md) — Global runtime services (Java only)
* [Cache Providers](/boxlang-framework/module-development/capabilities/cache-providers.md) — Custom caching backends (Java only)
* [Packaging & Publishing](/boxlang-framework/module-development/packaging-publishing.md) — Build and distribute your module


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/module-development/capabilities/jdbc-drivers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
