database-metadata-bind
A library for binding various information from DatabaseMetaData.
All methods defined in DatabaseMetaData meet following conditions have been defined along with corresponding result types.
- is an instance method.
- has at least one parameter
- (and/or) result type is ResultSet.
Usage
java.sql.Connection connection = connect();
Context context = Context.newInstance(connection)
.suppress(SQLFeatureNotSupportedException.class);
List<Catalog> catalogs = context.getCatalogs(new ArrayList<>());
if (catalogs.isEmpty()) {
catalogs.add(Catalog.newVirtualInstance());
}
for (Catalog catalog : catalogs) {
context.getSchemas(catalog, null, catalog.getSchemas());
if (catalog.getSchemas().isEmpty()) {
catalog.getSchemas().add(Schema.newVirtualInstance(catalog));
}
for (Schema schema : catalog.getSchemas()) {
context.getTables(schema, "%", null, schema.getTables());
}
}
// Gather almost all information
Metadata metadata = Metadata.newInstance(cotext);Gathering metadata from existing databases
$ mvn -Pfailsafe,external-<server> \
-Dversion.<client>=x.y.z \
-Durl=jdbc:...://... \
-Duser=... \
-Dpassword=... \
-Dit.test=ExternalIT \
verify
...
$ cat target/external.xml
...
$Properties
| name | value | notes |
|---|---|---|
<server> |
server identifier | see below |
version.<client> |
version of <client> |
see below |
url |
connection url | |
user |
user | |
password |
password |
<server> / <client>
| database | <server> |
<client> |
|---|---|---|
| MariaDB | mariadb |
mariadb-java-client |
| MySQL | mysql |
mysql-connector-java |
| Oracle | oracle-ojdbc6 |
ojdbc6 |
| Oracle | oracle-ojdbc8 |
ojdbc8 |
| Oracle | oracle-ojdbc10 |
ojdbc10 |
| Oracle | oracle-ojdbc11 |
ojdbc11 |
| PostgreSQL | postgresql |
postgresql |
| SQL Server | sqlserver |
mssql-jdbc |
e.g.
$ mvn -Pfailsafe,external-mysql \
-Dversion.mysql-connector-java=8.0.25
-Durl=jdbc:mysql://host:port/database
-Duser=...
-Dpassword=...
-Dit.test=ExternalIT \
verify
...
$ $ mvn -Pexternal-oracle-ojdbc11 \
-Dversion-ojdbc11=21.1.0.0 \
-Durl=jdbc:oracle:thin:@//host:port/service \
-Duser=scott \
-Dpassword=tiger \
-Dit.test=ExternalIT \
verify
...
$ 