> 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

{% 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
