-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Jin Kwon edited this page Jul 6, 2026
·
5 revisions
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 typed List<T> and forEach... methods for JDBC metadata result sets such as getTables, getColumns, getPrimaryKeys, getImportedKeys, and getTypeInfo.
| Item | Value |
|---|---|
| Maven coordinates | io.github.jinahya:database-metadata-bind |
| Current source version | 4.5.1-SNAPSHOT |
| Java main source level | 17 |
| Java test source level | 25 |
| Build Java requirement | JDK 25 or newer |
| Maven requirement | Maven 3.6.3 or newer |
| Automatic module name | com.github.jinahya.database.metadata.bind |
| Package | com.github.jinahya.database.metadata.bind |
| License | Apache License 2.0 |
Check Maven Central for released versions.
<dependency>
<groupId>io.github.jinahya</groupId>
<artifactId>database-metadata-bind</artifactId>
<version><!-- released version --></version>
</dependency>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.newInstance(Connection) calls Connection.getMetaData(). Context also has a public constructor for callers that already have a DatabaseMetaData instance.
var context = new Context(connection.getMetaData());For large result sets, use the forEach... variants to consume bound rows without first building a list.
context.forEachTable(null, null, "%", null, table -> {
// inspect each Table as it is bound
});The API follows DatabaseMetaData conventions:
-
nullparameters keep the JDBC driver's original meaning, usually "do not narrow by this value" or "not applicable". - Pattern parameters such as
schemaPattern,tableNamePattern, andcolumnNamePatternare passed directly to the JDBC driver. - Result properties that JDBC may report as SQL
NULLare exposed as nullable wrapper types or nullable strings. - Driver-specific result-set columns that are not mapped by the library are preserved in
MetadataType.getUnknownColumns().
-
API Reference:
Contextmethods, convenience sweeps, string-list helpers, and bound result types. - Model Notes: binding behavior, unknown columns, nullness, relationships, comparators, and validation predicates.
- Testing and Build: Maven requirements, memory database tests, Testcontainers profiles, and external database tests.
-
Known Issues: current issues summarized from
doc/issues.md.