|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.brains2b.sql.meta.SQLMetaData
public class SQLMetaData
Main DatabaseMetaData class for describing database, table and column properties on the basis of a supplied connection
Constructor Summary | |
---|---|
SQLMetaData()
Default Constructor |
|
SQLMetaData(java.sql.Connection connection)
Constructor for SqlMetadata |
Method Summary | |
---|---|
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 |
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SQLMetaData()
Use setConnection(Connection)
prior
to using any of the methods
public SQLMetaData(java.sql.Connection connection)
connection
- Connection, the database connection usedMethod Detail |
---|
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
SQLException,
- from the connection
java.sql.SQLException
public java.util.List getCatalogs() throws java.sql.SQLException
java.sql.SQLException
public java.util.List getSchemas() throws java.sql.SQLException
java.sql.SQLException
public java.util.List getTableTypes() throws java.sql.SQLException
Note:Types does not return synonym
java.sql.SQLException
public 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,
- a possible tablePattern, null if not used.
java.sql.SQLException
#getTables, #getColumns
,
for information on catalogs and patterns
public 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,
- a possible tablePattern, null if not used.
java.sql.SQLException
for information on catalogs and patterns
public 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,
- a possible tablePattern, null if not used.
java.sql.SQLException
for information on catalogs and patterns
,
#getTableTypes()}
public void setColumns(TableModel table) throws java.sql.SQLException
proc
- ProcedureModel, the model to set the parameters to
java.sql.SQLException
#getColumns(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,
- a possible tablePattern, null if not used.columnPattern,
- a possible columnPattern, null if not used.
java.sql.SQLException
for information on catalogs and patterns
public 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 for
java.sql.SQLException
public 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 for
java.sql.SQLException
public void setIndices(TableModel table, boolean onlyUnique) throws java.sql.SQLException
proc
- ProcedureModel, the model to set the parameters to
java.sql.SQLException
#getColumns(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,
- a possible tablePattern matching the name of the TableModelonlyUnique,
- true if only unique indexes should be retrieved
java.sql.SQLException
public 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.SQLException
public 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.SQLException
public void setParameters(ProcedureModel proc) throws java.sql.SQLException
proc
- ProcedureModel, the model to set the parameters to
java.sql.SQLException
#getParameters(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 procedures
ParameterModel
java.sql.SQLException
public 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 usedpattern
- 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 types
java.sql.SQLException
public TypesInfo getTypeInfo()
Connection
or DatabaseMetaData
cannot be found
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |