|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fesenmeyer.dbnormalizer.core.dbaccess.DatabaseMetadataUtil
public final class DatabaseMetadataUtil
Utility class for retrieving database information. Acts as a facade
to SQuirreL and DatabaseMetaData
code.
DatabaseMetaData
Field Summary | |
---|---|
private static DBNormalizerLogger |
logger
The logger for this class. |
Constructor Summary | |
---|---|
DatabaseMetadataUtil()
|
Method Summary | |
---|---|
private static Collection<FK> |
buildFKsFromResultSet(ResultSet rs)
Helper method creating a collection of FKs from the ResultSet returned from the DatabaseMetaData.getImportedKeys(String, String, String)
or DatabaseMetaData.getExportedKeys(String, String, String) method. |
private static String |
createFKKey(FK fk)
Helper method which creates a string which can be used as a FK's key in a map. |
private static Table |
createTableFromTableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo tableInfo)
Helper method which converts from SQuirreL's ITableInfo object to DBNormalizer's Table object. |
static Collection<String> |
getCatalogs(DBNormalizerSession session)
Gets the catalogs for the specified DBNormalizer session. |
static Collection<FK> |
getExportedKeys(DatabaseMetaData dbmd,
String catalog,
String schema,
String tableName)
Gets the exported keys for a table specified by catalog, schema and name. |
static Collection<FK> |
getImportedKeys(DatabaseMetaData dbmd,
String catalog,
String schema,
String tableName)
Gets the imported keys for a table specified by catalog, schema and name. |
static PK |
getPK(DBNormalizerSession session,
String catalog,
String schema,
String tableName)
Gets the PK for a table specified by catalog, schema and name. |
static Collection<String> |
getSchemas(DBNormalizerSession session)
Gets the schemas for the specified DBNormalizer session. |
static Collection<TableColumn> |
getTableColumnInfos(DBNormalizerSession session,
String catalogName,
String schemaName,
String tableName)
Gets TableColumn objects for a table specified by catalog, schema and name. |
static Collection<TableContainer> |
getTableContainers(DBNormalizerSession session)
Gets all TableContainers (catalogs or schemas) for the specified DBNormalizer session. |
static Table |
getTableInfo(DBNormalizerSession session,
String catalogName,
String schemaName,
String tableName,
boolean complete)
Gets the table with the specified name, catalog and schema. |
static Collection<Table> |
getTableInfos(DBNormalizerSession session,
String catalogName,
String schemaName)
Gets all tables from the specified catalog or schema. |
static Collection<Table> |
getTableInfos(DBNormalizerSession session,
String catalogName,
String schemaName,
boolean complete)
Gets all tables from the specified catalog or schema. |
static Collection<Table> |
getTableInfos(DBNormalizerSession session,
TableContainer tableContainer,
boolean complete)
Gets all tables from the specified TableContainer. |
private static void |
retrieveCompleteTableInfo(DBNormalizerSession session,
Table table)
Helper method which fills the given table object with further information (Column, PK and FK information). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static DBNormalizerLogger logger
Constructor Detail |
---|
public DatabaseMetadataUtil()
Method Detail |
---|
public static Collection<Table> getTableInfos(DBNormalizerSession session, String catalogName, String schemaName) throws SQLException
NOTE: The returned table objects are not completely filled due
to performance issues, but only contain the table's name, catalog, schema
and TableContainer. To get all available information, use the
getTableInfos(DBNormalizerSession, String, String, boolean)
method
or get further information by other methods of this class (e.g.
getTableColumnInfos(DBNormalizerSession, String, String, String)
.
session
- the DBNormalizer session which is connected to the DBcatalogName
- the catalog's name, may be null
schemaName
- the schema's name, may be null
SQLException
public static Collection<Table> getTableInfos(DBNormalizerSession session, String catalogName, String schemaName, boolean complete) throws SQLException
NOTE: If you set the argument complete
to false
,
the returned table objects will not be completely filled,
but only contain the table's name, catalog, schema
and TableContainer. To get all available information,
which is not high-performance,
set the argument complete
to true
.
session
- the DBNormalizer session which is connected to the DBcatalogName
- the catalog's name, may be null
schemaName
- the schema's name, may be null
complete
- true
, to read all available information;
false
, otherwise
SQLException
public static Collection<Table> getTableInfos(DBNormalizerSession session, TableContainer tableContainer, boolean complete) throws SQLException
NOTE: If you set the argument complete
to false
,
the returned table objects will not be completely filled,
but only contain the table's name, catalog, schema
and TableContainer. To get all available information,
which is not high-performance,
set the argument complete
to true
.
session
- the DBNormalizer session which is connected to the DBtableContainer
- the TableContainercomplete
- true
, to read all available information;
false
, otherwise
SQLException
private static Table createTableFromTableInfo(net.sourceforge.squirrel_sql.fw.sql.ITableInfo tableInfo)
tableInfo
- an ITableInfo object
public static Collection<TableContainer> getTableContainers(DBNormalizerSession session) throws SQLException
session
- the DBNormalizer-Session
SQLException
public static Table getTableInfo(DBNormalizerSession session, String catalogName, String schemaName, String tableName, boolean complete) throws SQLException
NOTE: If you set the argument complete
to false
,
the returned table object will not be completely filled,
but only contain the table's name, catalog, schema
and TableContainer. To get all available information,
which is not high-performance,
set the argument complete
to true
.
session
- the DBNormalizer session which is connected to the DBcatalogName
- the catalog's name, may be null
schemaName
- the schema's name, may be null
tableName
- the table's (simple) namecomplete
- true
, to read all available information;
false
, otherwise
null
, otherwise
SQLException
private static void retrieveCompleteTableInfo(DBNormalizerSession session, Table table) throws SQLException
session
- the DBNormalizer session which is connected to the DBtable
- a table object
SQLException
public static Collection<String> getCatalogs(DBNormalizerSession session) throws SQLException
session
- the DBNormalizer session which is connected to the DB
SQLException
public static Collection<String> getSchemas(DBNormalizerSession session) throws SQLException
session
- the DBNormalizer session which is connected to the DB
SQLException
public static Collection<FK> getImportedKeys(DatabaseMetaData dbmd, String catalog, String schema, String tableName) throws SQLException
dbmd
- a SQL-DatabaseMetaData-objectcatalog
- the table's catalog, may be null
schema
- the table's schema, may be null
tableName
- the table's (simple) name
SQLException
DatabaseMetaData.getImportedKeys(String, String, String)
public static Collection<FK> getExportedKeys(DatabaseMetaData dbmd, String catalog, String schema, String tableName) throws SQLException
dbmd
- a SQL-DatabaseMetaData-objectcatalog
- the table's catalog, may be null
schema
- the table's schema, may be null
tableName
- the table's (simple) name
SQLException
DatabaseMetaData.getExportedKeys(String, String, String)
private static Collection<FK> buildFKsFromResultSet(ResultSet rs) throws SQLException
DatabaseMetaData.getImportedKeys(String, String, String)
or DatabaseMetaData.getExportedKeys(String, String, String)
method.
rs
- the ResultSet
SQLException
private static String createFKKey(FK fk)
fk
- a FK
public static PK getPK(DBNormalizerSession session, String catalog, String schema, String tableName) throws SQLException
session
- the DBNormalizer session which is connected to the DBcatalog
- the table's catalog, may be null
schema
- the table's schema, may be null
tableName
- the table's (simple) name
null
, otherwise
SQLException
public static Collection<TableColumn> getTableColumnInfos(DBNormalizerSession session, String catalogName, String schemaName, String tableName) throws SQLException
session
- the DBNormalizer session which is connected to the DBcatalogName
- the table's catalog, may be null
schemaName
- the table's schema, may be null
tableName
- the table's (simple) name
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |