public class SQLMetaData
extends java.lang.Object
| Constructor and Description |
|---|
SQLMetaData()
Default Constructor
|
SQLMetaData(java.sql.Connection connection)
Constructor for SqlMetadata
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List |
getCatalogs()
get the catalog names which can be retrieved for this database
|
java.util.List |
getColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String columnPattern)
get a List of SqlColumModels for each colum that can be found for the parameters supplied.
|
java.sql.Connection |
getConnection()
get the connection to the Database
|
java.util.List |
getConstraints(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String type)
get a List of Constraints (Primary | Foreign ) defined in this database for the
given catalog,schema and pattern.
|
java.util.List |
getIndices(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
boolean onlyUnique)
get a list of Indices for the given parameters.
|
java.sql.DatabaseMetaData |
getMetaData()
get the DatabaseMetaData object associated with the connection used
|
java.util.List |
getParameters(java.lang.String catalog,
java.lang.String schema,
java.lang.String procName)
get the parameters belonging to the procedure
|
java.util.List |
getProcedures(java.lang.String catalog,
java.lang.String schema,
java.lang.String pattern)
get a List of Procedures defined in this database without possible parameters
for the given catalog,schema and pattern.
|
java.util.List |
getProcedures(java.lang.String catalog,
java.lang.String schema,
java.lang.String pattern,
boolean includeParms)
get a List of Procedures defined in this database for the
given catalog,schema and pattern.
|
java.util.List |
getSchemas()
get the schema names which can be retrieved for this database
|
java.util.List |
getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern)
get a List of TableModel objects, without their columns
dependant on the parameters supplied.
|
java.util.List |
getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String type)
get a List of TableModel objects for a specific type, without their columns
dependant on the parameters supplied.
|
java.util.List |
getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String type,
boolean includeDeleted)
get a List of TableModel objects for a specific type, without their columns
dependant on the parameters supplied.
|
java.util.List |
getTablesWithColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern)
get a List of TableModel objects, including their columns
dependant on the parameters supplied.
|
java.util.List |
getTableTypes()
get the table types supported by the database
|
TypesInfo |
getTypeInfo()
get a Types2Java object for transforming types between
the database and Java
|
void |
setColumns(TableModel table)
set the columns for this table
|
void |
setConnection(java.sql.Connection con)
set the connection to the Database to
use for the MetaData
|
void |
setIndices(TableModel table,
boolean onlyUnique)
set the Indexes for this table
|
void |
setParameters(ProcedureModel proc)
set the parameters for this procedure
|
void |
setPrimaryKey(TableModel tm)
set the primary key belonging to a table
|
void |
setPrimaryKey(TableModel tm,
boolean forceRowid)
set the primary key belonging to a table
|
void |
setPrimaryKey(TableModel tm,
boolean forceRowid,
boolean addColumn)
set the primary key belonging to a table
|
public SQLMetaData()
Use setConnection(Connection) prior
to using any of the methods
public SQLMetaData(java.sql.Connection connection)
connection - Connection, the database connection usedpublic java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
SQLException, - from the connectionjava.sql.SQLExceptionpublic java.util.List getCatalogs()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.List getSchemas()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.List getTableTypes()
throws java.sql.SQLException
Note:Types does not return synonym
java.sql.SQLExceptionpublic java.util.List getTablesWithColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern, null if not used.java.sql.SQLExceptiongetTables(String, String, String),
getColumns(String, String, String, String),
for information on catalogs and patternspublic java.util.List getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern, null if not used.java.sql.SQLExceptionfor information on catalogs and patternspublic java.util.List getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String type)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern, null if not used.type - String, a type from getTableTypes()java.sql.SQLExceptionfor information on catalogs and patterns,
getTableTypes()public java.util.List getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String type,
boolean includeDeleted)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern, null if not used.type - String, a type from getTableTypes()includeDeleted - boolean true to include tables which already have been removed or trashed ( if supported by database )java.sql.SQLExceptionfor information on catalogs and patterns,
getTableTypes()public void setColumns(TableModel table) throws java.sql.SQLException
table - TableModel, the model to set the parameters tojava.sql.SQLExceptiongetColumns(String, String, String, String)public java.util.List getColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
java.lang.String columnPattern)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern, null if not used.columnPattern - String, a possible columnPattern, null if not used.java.sql.SQLExceptionfor information on catalogs and patternspublic void setPrimaryKey(TableModel tm) throws java.sql.SQLException
The method returns the table model enriched with a possible primary key. If no primary key can be found a primary key is constructed from possiblem unique indexes. If no unique indexes where defined a pseudo column called ROWID is created.
tm - TableModel, the table to find the primary key forjava.sql.SQLExceptionpublic void setPrimaryKey(TableModel tm, boolean forceRowid) throws java.sql.SQLException
The method enriches the TableModel with a possible primary key. If no primary key can be found a primary key is constructed from possiblem unique indexes. If no unique indexes where defined a pseudo column called ROWID is created.
tm - TableModel, the table to find the primary key forforceRowid - boolean true to add a rowid as primary key, normal primary keys are ignoredjava.sql.SQLExceptionpublic void setPrimaryKey(TableModel tm, boolean forceRowid, boolean addColumn) throws java.sql.SQLException
The method enriches the TableModel with a possible primary key. If no primary key can be found a primary key is constructed from possiblem unique indexes. If no unique indexes where defined a pseudo column called ROWID is created.
tm - TableModel, the table to find the primary key forforceRowid - boolean true to add a rowid as primary key, normal primary keys are ignoredaddColumn - bollean true to also add rowid as column to the table and the primary keyjava.sql.SQLExceptionpublic void setIndices(TableModel table, boolean onlyUnique) throws java.sql.SQLException
table - TableModel, the model to set the parameters toonlyUnique - booleanjava.sql.SQLExceptiongetColumns(String, String, String, String)public java.util.List getIndices(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tablePattern,
boolean onlyUnique)
throws java.sql.SQLException
catalog - String, a possible catalog name, null if not usedschemaPattern - String, a possible schemaPattern, null if not usedtablePattern - String, a possible tablePattern matching the name of the TableModelonlyUnique - boolean, true if only unique indexes should be retrievedjava.sql.SQLExceptionpublic java.util.List getProcedures(java.lang.String catalog,
java.lang.String schema,
java.lang.String pattern)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschema - String, a possible schemaPattern, null if not usedpattern - String, a possible tablePattern, null if not used.java.sql.SQLExceptionpublic java.util.List getProcedures(java.lang.String catalog,
java.lang.String schema,
java.lang.String pattern,
boolean includeParms)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschema - String, a possible schemaPattern, null if not usedpattern - String, a possible tablePattern, null if not used.includeParms - boolean, true if you want the parameters for this
procedure loaded as well, false otherwise.
Note: Setting this to true might slow down the result
java.sql.SQLExceptionpublic void setParameters(ProcedureModel proc) throws java.sql.SQLException
proc - ProcedureModel, the model to set the parameters tojava.sql.SQLExceptiongetParameters(String, String, String)public java.util.List getParameters(java.lang.String catalog,
java.lang.String schema,
java.lang.String procName)
throws java.sql.SQLException
catalog - String, catalog or nullschema - String, schema or nullprocName - String, the name of the procedure, leaving
this blank will return the parameters of all proceduresParameterModeljava.sql.SQLExceptionpublic java.sql.Connection getConnection()
public void setConnection(java.sql.Connection con)
con - Connection, the connection to the Databasepublic java.util.List getConstraints(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String type)
throws java.sql.SQLException
Setting any of the parameters to null will ignore them. Setting either catalog or schemaPattern is usually necessary.
catalog - String, a possible catalog name, null if not usedschema - String, a possible schemaPattern, null if not usedtable - String, a possible tablePattern, null if not used.type - String, the type of constraint to get ( ConstraintModel.PRIMARY_KEY | Constraint.FOREIGN_KEY )
or null for both typesjava.sql.SQLExceptionpublic TypesInfo getTypeInfo()
Connection or DatabaseMetaData
cannot be found