@Immutable public class JdbcMetadataCollector extends Object implements MetadataCollector
MetadataCollector
implementation that uses the built-in JDBC support
for collecting
database metadata.DatabaseMetaData
Constructor and Description |
---|
JdbcMetadataCollector() |
Modifier and Type | Method and Description |
---|---|
List<String> |
getCatalogNames(Connection conn)
Return the list of catalog names that currently exist in the database to which
connection is connected. |
List<ColumnMetadata> |
getColumns(Connection conn,
String catalogName,
String schemaName,
String tableName,
String columnName)
Return the list of columns that currently exist in the database to which
connection is connected within the named
catalog (if catalogName is non-null), named schema (if schemaName is non-null), and named table. |
DBMetadata |
getDatabaseMetadata(Connection conn)
Return metadata information about the database to which
connection is connected. |
List<ForeignKeyMetadata> |
getForeignKeys(Connection conn,
String catalogName,
String schemaName,
String tableName,
String fkColumnName)
Return the list of foreign keys import by a table that currently exist in the database to which
connection is connected within the named catalog (if catalogName is non-null),
named schema (if schemaName is non-null), and named table. |
List<ProcedureMetadata> |
getProcedures(Connection conn,
String catalogName,
String schemaName,
String procedureName)
Return the list of procedures that currently exist in the database to which
connection is connected within the
named catalog (if catalogName is non-null) and named schema (if schemaName is non-null). |
List<String> |
getSchemaNames(Connection conn,
String catalogName)
Return the list of schema names that currently exist in the database to which
connection is connected within the
named catalog. |
List<TableMetadata> |
getTables(Connection conn,
String catalogName,
String schemaName,
String tableName)
Return the list of tables that currently exist in the database to which
connection is connected within the named
catalog (if catalogName is non-null) and named schema (if schemaName is non-null). |
public DBMetadata getDatabaseMetadata(Connection conn) throws JdbcMetadataException
MetadataCollector
connection
is connected.getDatabaseMetadata
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.DBMetadata
instance, never null
JdbcMetadataException
- if the metadata cannot be retrievedpublic List<String> getCatalogNames(Connection conn) throws JdbcMetadataException
MetadataCollector
connection
is connected. The names
must be sorted in a manner that is stable between successive calls to this method.getCatalogNames
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.JdbcMetadataException
- if the catalog names cannot be retrievedDatabaseMetaData.getCatalogs()
public List<ColumnMetadata> getColumns(Connection conn, String catalogName, String schemaName, String tableName, String columnName) throws JdbcMetadataException
MetadataCollector
connection
is connected within the named
catalog (if catalogName
is non-null), named schema (if schemaName
is non-null), and named table. If columnName
is null, then all columns which conform to the catalog, schema, and table restrictions noted previously should
be returned. If columnName
is non-null, then only the column that exactly matches that name should be returned. The
column metadata must be sorted in a manner that is stable between successive calls to this method.getColumns
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.catalogName
- the name of the catalog to which returned columns must belong, or null if columns are to be returned
without regard to their catalogschemaName
- the name of the schema to which returned columns must belong, or null if columns are to be returned
without regard to their schematableName
- the name of the table to which returned columns must belong; may not be nullcolumnName
- the name of the column to be returned, or null if all columns within the given catalog, schema, and table
are to be returnedJdbcMetadataException
- if the column metadata cannot be retrievedDatabaseMetaData.getColumns(String, String, String, String)
public List<String> getSchemaNames(Connection conn, String catalogName) throws JdbcMetadataException
MetadataCollector
connection
is connected within the
named catalog. If catalogName
is null, then all schema names should be returned regardless of the catalog with
which they are associated. The schema names must be sorted in a manner that is stable between successive calls to this
method.getSchemaNames
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.catalogName
- the name of the catalog to which returned schemas must belong, or null if all schemas are to be returnedJdbcMetadataException
- if the schema names cannot be retrievedDatabaseMetaData.getSchemas()
public List<TableMetadata> getTables(Connection conn, String catalogName, String schemaName, String tableName) throws JdbcMetadataException
MetadataCollector
connection
is connected within the named
catalog (if catalogName
is non-null) and named schema (if schemaName
is non-null). If tableName
is
null, then all tables which conform to the catalog and schema restriction noted previously should be returned. If tableName
is non-null, then only the table(s) that exactly match that name should be returned. The table metadata must be
sorted in a manner that is stable between successive calls to this method.getTables
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.catalogName
- the name of the catalog to which returned tables must belong, or null if tables are to be returned
without regard to their catalogschemaName
- the name of the schema to which returned tables must belong, or null if tables are to be returned without
regard to their schematableName
- the name of the table to be returned, or null if all tables within the given catalog and schema are to be
returnedJdbcMetadataException
- if the table metadata cannot be retrievedDatabaseMetaData.getTables(String, String, String, String[])
public List<ProcedureMetadata> getProcedures(Connection conn, String catalogName, String schemaName, String procedureName) throws JdbcMetadataException
MetadataCollector
connection
is connected within the
named catalog (if catalogName
is non-null) and named schema (if schemaName
is non-null). If procedureName
is null, then all procedures which conform to the catalog and schema restriction noted previously should be
returned. If procedureName
is non-null, then only the procedure(s) that exactly match that name should be returned.
The procedure metadata must be sorted in a manner that is stable between successive calls to this method.getProcedures
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.catalogName
- the name of the catalog to which returned procedures must belong, or null if procedures are to be
returned without regard to their catalogschemaName
- the name of the schema to which returned procedures must belong, or null if procedures are to be returned
without regard to their schemaprocedureName
- the name of the procedure(s) to be returned, or null if all procedures within the given catalog and
schema are to be returnedJdbcMetadataException
- if the procedure metadata cannot be retrievedpublic List<ForeignKeyMetadata> getForeignKeys(Connection conn, String catalogName, String schemaName, String tableName, String fkColumnName) throws JdbcMetadataException
MetadataCollector
connection
is connected within the named catalog (if catalogName
is non-null),
named schema (if schemaName
is non-null), and named table.getForeignKeys
in interface MetadataCollector
conn
- the connection to the database; must not be non-null and must be open. This connection should not be closed by
this method.catalogName
- the name of the catalog to which returned columns must belong, or null if columns are to be returned
without regard to their catalogschemaName
- the name of the schema to which returned columns must belong, or null if columns are to be returned
without regard to their schematableName
- the name of the table to which returned columns must belong; may not be nullfkColumnName
- the name of the foreign key column for which to retrieve metadata; may be null. If that is the case,
all the foreign keys will be retrieved.JdbcMetadataException
- if the column metadata cannot be retrievedDatabaseMetaData.getImportedKeys(String, String, String)
Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.