For the complete documentation index, see llms.txt. This page is also available as Markdown.

JDBC Drivers

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

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:

Implement java.sql.Driver and register via DriverManager:

File: src/main/java/ortus/boxlang/modules/mymodule/jdbc/MyJDBCDriver.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

Module Structure

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

Open Source JDBC Modules

Reference these existing JDBC driver modules:

Module
Database

bx-mysql

MySQL/MariaDB

bx-postgresql

PostgreSQL

bx-mssql

SQL Server

bx-oracle

Oracle

bx-sqlite

SQLite

bx-derby

Apache Derby

Next Steps

Last updated

Was this helpful?