Skip to content
Jin Kwon edited this page Jun 29, 2026 · 5 revisions

database-metadata-bind

database-metadata-bind is a Java library that binds java.sql.DatabaseMetaData ResultSet rows to typed Java objects.

The main entry point is com.github.jinahya.database.metadata.bind.Context. A Context wraps a DatabaseMetaData instance and exposes list-returning methods for the JDBC metadata result sets, such as getTables, getColumns, getPrimaryKeys, getImportedKeys, and getTypeInfo.

Project Snapshot

Item Value
Maven coordinates io.github.jinahya:database-metadata-bind
Current source version 4.4.1-SNAPSHOT
Java main source level 11
Java test source level 25
Automatic module name com.github.jinahya.database.metadata.bind
Package com.github.jinahya.database.metadata.bind
License Apache License 2.0

Installation

Check Maven Central for released versions.

<dependency>
  <groupId>io.github.jinahya</groupId>
  <artifactId>database-metadata-bind</artifactId>
  <version><!-- released version --></version>
</dependency>

Basic Usage

try (var connection = dataSource.getConnection()) {
    var context = Context.newInstance(connection);

    var catalogs = context.getCatalogs();
    var schemas = context.getSchemas();
    var tables = context.getTables(null, null, "%", null);

    for (var table : tables) {
        var columns = context.getColumns(
                table.getTableCat(),
                table.getTableSchem(),
                table.getTableName(),
                "%"
        );

        var primaryKeys = context.getPrimaryKeys(
                table.getTableCat(),
                table.getTableSchem(),
                table.getTableName()
        );
    }
}

Context also has a public constructor for callers that already have a DatabaseMetaData instance.

var context = new Context(connection.getMetaData());

Nulls And Patterns

The API follows DatabaseMetaData conventions:

  • null parameters keep the JDBC driver's original meaning, usually "do not narrow by this value" or "not applicable".
  • Pattern parameters such as schemaPattern, tableNamePattern, and columnNamePattern are passed directly to the JDBC driver.
  • Result properties that JDBC may report as SQL NULL are exposed as nullable wrapper types or nullable strings.

Wiki Pages

  • API Reference: Context methods and the bound result types.
  • Model Notes: metadata object relationships, unknown columns, nullness, and ordering notes.
  • Testing and Build: Maven commands, memory database tests, Testcontainers profiles, and external database tests.
  • Known Issues: current issues noted in the repository analysis document.

External Links

Clone this wiki locally