Class DBMDWrapper
- All Implemented Interfaces:
OptionalTool
OptionalTool to create wrapper functions which allow you to invoke DatabaseMetaData methods via SQL. The wrapper functions slightly change the signature of the metadata methods as follows:
- Arguments of type int[] and String[] have been eliminated--they are automatically wildcarded.
- The method getRowIdLifetime() has been commented out--Derby does not support object types.
- The method getSchemas() has been commented out--it can be uncommented when the registration logic is made smarter to handle the dropping of different overloads.
- The method supportsConvert() has been commented out because Derby only allows one function by a given name and the supportsConvert( int, int ) overload is more general.
Methods which return ResultSet are mapped to table functions. You can join the metadata table functions like this:
-- list all of the columns in the connected Derby database select t.table_schem, t.table_name, c.column_name, c.type_name from table( getTables( null, null, null ) ) t, table( getColumns( null, null, null, null ) ) c where c.table_schem = t.table_schem and c.table_name = t.table_name and t.table_type = 'TABLE' ; -- now list metadata in a foreign database call setDatabaseURL( 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost/world?user=root&password=' ); select t.table_schem, t.table_name, c.column_name, c.type_name from table( getTables( 'WORLD', null, null ) ) t, table( getColumns( 'WORLD', null, null, null) ) c where c.table_name = t.table_name and t.table_type = 'TABLE' ; -- release the foreign connection call setDatabaseURL( '', '' );
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static boolean
private void
appendArgs
(StringBuffer buffer, Method method) Append function arguments to an evolving ddl text buffer.private void
appendReturnType
(StringBuffer buffer, Connection conn, Method method) Append return type to an evolving ddl text bufferprivate void
appendTableFunctionSignature
(StringBuffer buffer, Connection conn, Method method) Append the signature of a table function to an evolving ddl text bufferstatic boolean
static boolean
static boolean
static boolean
deletesAreDetected
(int type) static boolean
private static void
executeDDL
(Connection conn, String text) Execute a DDL statement.static ResultSet
getAttributes
(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) static ResultSet
getBestRowIdentifier
(String catalog, String schema, String table, int scope, boolean nullable) static ResultSet
static String
static String
static ResultSet
static ResultSet
getColumnPrivileges
(String catalog, String schema, String table, String columnNamePattern) static ResultSet
getColumns
(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) static ResultSet
getCrossReference
(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) static int
static int
static String
static String
private static DatabaseMetaData
getDBMD()
Get the current session's database metadata.private static Connection
Get the default connection, called from inside the database engine.static int
static int
static int
static String
static String
private Object
getDummyValue
(Class type) Get a dummy value for an argument to a DBMD method.static ResultSet
getExportedKeys
(String catalog, String schema, String table) static String
static ResultSet
getFunctionColumns
(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) static ResultSet
getFunctions
(String catalog, String schemaPattern, String functionNamePattern) static String
static ResultSet
getImportedKeys
(String catalog, String schema, String table) static ResultSet
getIndexInfo
(String catalog, String schema, String table, boolean unique, boolean approximate) static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static int
static String
static ResultSet
getPrimaryKeys
(String catalog, String schema, String table) static ResultSet
getProcedureColumns
(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) static ResultSet
getProcedures
(String catalog, String schemaPattern, String procedureNamePattern) static String
static int
static ResultSet
getSchemas
(String catalog, String schemaPattern) static String
static String
static String
static int
static String
static ResultSet
getSuperTables
(String catalog, String schemaPattern, String tableNamePattern) static ResultSet
getSuperTypes
(String catalog, String schemaPattern, String typeNamePattern) static String
static ResultSet
getTablePrivileges
(String catalog, String schemaPattern, String tableNamePattern) static ResultSet
static ResultSet
static String
static ResultSet
static ResultSet
static String
getURL()
static String
static ResultSet
getVersionColumns
(String catalog, String schema, String table) static boolean
insertsAreDetected
(int type) static boolean
static boolean
private boolean
isSet
(int allModifiers, int requestedModifier) Return true if the requested modifer is setprivate boolean
isTableFunction
(Method method) Return true if the method describes a table function.void
Load the tool, giving it optional configuration parametersstatic boolean
private String
mapJavaToSQLType
(Class javaType) Get the SQL type which corresponds to a Java type.static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
othersDeletesAreVisible
(int type) static boolean
othersInsertsAreVisible
(int type) static boolean
othersUpdatesAreVisible
(int type) static boolean
ownDeletesAreVisible
(int type) static boolean
ownInsertsAreVisible
(int type) static boolean
ownUpdatesAreVisible
(int type) private static PreparedStatement
prepareStatement
(Connection conn, String text) Prepare a statement and print out the text.private void
register
(boolean register) Workhorse to register or unregister all public static methods as Derby routines.private void
registerFunction
(Connection conn, Method method) Register the method as a Derby function.static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
private void
stringifyJDBCType
(StringBuffer buffer, ResultSetMetaData rsmd, int columnNumber) Append the name of a SQL type to an evolving ddl text bufferstatic boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
supportsConvert
(int fromType, int toType) static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
supportsResultSetConcurrency
(int type, int concurrency) static boolean
supportsResultSetHoldability
(int holdability) static boolean
supportsResultSetType
(int type) static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
supportsTransactionIsolationLevel
(int level) static boolean
static boolean
static boolean
void
unloadTool
(String... configurationParameters) Unload the tool, giving it optional configuration parametersprivate void
unregisterFunction
(Connection conn, Method method) Drop the function with this method name.static boolean
updatesAreDetected
(int type) static boolean
static boolean
private static SQLException
Wrap an exception in a SQLException.
-
Field Details
-
DEFAULT_PRECISION
private static final int DEFAULT_PRECISION- See Also:
-
-
Constructor Details
-
DBMDWrapper
public DBMDWrapper()0-arg constructor to satisfy the OptionalTool contract
-
-
Method Details
-
loadTool
Description copied from interface:OptionalTool
Load the tool, giving it optional configuration parameters- Specified by:
loadTool
in interfaceOptionalTool
- Throws:
SQLException
-
unloadTool
Description copied from interface:OptionalTool
Unload the tool, giving it optional configuration parameters- Specified by:
unloadTool
in interfaceOptionalTool
- Throws:
SQLException
-
register
Workhorse to register or unregister all public static methods as Derby routines.
- Throws:
SQLException
-
allProceduresAreCallable
- Throws:
SQLException
-
allTablesAreSelectable
- Throws:
SQLException
-
autoCommitFailureClosesAllResultSets
- Throws:
SQLException
-
dataDefinitionCausesTransactionCommit
- Throws:
SQLException
-
dataDefinitionIgnoredInTransactions
- Throws:
SQLException
-
deletesAreDetected
- Throws:
SQLException
-
doesMaxRowSizeIncludeBlobs
- Throws:
SQLException
-
getAttributes
public static ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException - Throws:
SQLException
-
getBestRowIdentifier
public static ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException - Throws:
SQLException
-
getCatalogs
- Throws:
SQLException
-
getCatalogSeparator
- Throws:
SQLException
-
getCatalogTerm
- Throws:
SQLException
-
getClientInfoProperties
- Throws:
SQLException
-
getColumnPrivileges
public static ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException - Throws:
SQLException
-
getColumns
public static ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException - Throws:
SQLException
-
getCrossReference
public static ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException - Throws:
SQLException
-
getDatabaseMajorVersion
- Throws:
SQLException
-
getDatabaseMinorVersion
- Throws:
SQLException
-
getDatabaseProductName
- Throws:
SQLException
-
getDatabaseProductVersion
- Throws:
SQLException
-
getDefaultTransactionIsolation
- Throws:
SQLException
-
getDriverMajorVersion
- Throws:
SQLException
-
getDriverMinorVersion
- Throws:
SQLException
-
getDriverName
- Throws:
SQLException
-
getDriverVersion
- Throws:
SQLException
-
getExportedKeys
public static ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException - Throws:
SQLException
-
getExtraNameCharacters
- Throws:
SQLException
-
getFunctionColumns
public static ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException - Throws:
SQLException
-
getFunctions
public static ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException - Throws:
SQLException
-
getIdentifierQuoteString
- Throws:
SQLException
-
getImportedKeys
public static ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException - Throws:
SQLException
-
getIndexInfo
public static ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException - Throws:
SQLException
-
getJDBCMajorVersion
- Throws:
SQLException
-
getJDBCMinorVersion
- Throws:
SQLException
-
getMaxBinaryLiteralLength
- Throws:
SQLException
-
getMaxCatalogNameLength
- Throws:
SQLException
-
getMaxCharLiteralLength
- Throws:
SQLException
-
getMaxColumnNameLength
- Throws:
SQLException
-
getMaxColumnsInGroupBy
- Throws:
SQLException
-
getMaxColumnsInIndex
- Throws:
SQLException
-
getMaxColumnsInOrderBy
- Throws:
SQLException
-
getMaxColumnsInSelect
- Throws:
SQLException
-
getMaxColumnsInTable
- Throws:
SQLException
-
getMaxConnections
- Throws:
SQLException
-
getMaxCursorNameLength
- Throws:
SQLException
-
getMaxIndexLength
- Throws:
SQLException
-
getMaxProcedureNameLength
- Throws:
SQLException
-
getMaxRowSize
- Throws:
SQLException
-
getMaxSchemaNameLength
- Throws:
SQLException
-
getMaxStatementLength
- Throws:
SQLException
-
getMaxStatements
- Throws:
SQLException
-
getMaxTableNameLength
- Throws:
SQLException
-
getMaxTablesInSelect
- Throws:
SQLException
-
getMaxUserNameLength
- Throws:
SQLException
-
getNumericFunctions
- Throws:
SQLException
-
getPrimaryKeys
public static ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException - Throws:
SQLException
-
getProcedureColumns
public static ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException - Throws:
SQLException
-
getProcedures
public static ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException - Throws:
SQLException
-
getProcedureTerm
- Throws:
SQLException
-
getResultSetHoldability
- Throws:
SQLException
-
getSchemas
- Throws:
SQLException
-
getSchemaTerm
- Throws:
SQLException
-
getSearchStringEscape
- Throws:
SQLException
-
getSQLKeywords
- Throws:
SQLException
-
getSQLStateType
- Throws:
SQLException
-
getStringFunctions
- Throws:
SQLException
-
getSuperTables
public static ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getSuperTypes
public static ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException - Throws:
SQLException
-
getSystemFunctions
- Throws:
SQLException
-
getTablePrivileges
public static ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getTables
public static ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException - Throws:
SQLException
-
getTableTypes
- Throws:
SQLException
-
getTimeDateFunctions
- Throws:
SQLException
-
getTypeInfo
- Throws:
SQLException
-
getUDTs
public static ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern) throws SQLException - Throws:
SQLException
-
getURL
- Throws:
SQLException
-
getUserName
- Throws:
SQLException
-
getVersionColumns
public static ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException - Throws:
SQLException
-
insertsAreDetected
- Throws:
SQLException
-
isCatalogAtStart
- Throws:
SQLException
-
isReadOnly
- Throws:
SQLException
-
locatorsUpdateCopy
- Throws:
SQLException
-
nullPlusNonNullIsNull
- Throws:
SQLException
-
nullsAreSortedAtEnd
- Throws:
SQLException
-
nullsAreSortedAtStart
- Throws:
SQLException
-
nullsAreSortedHigh
- Throws:
SQLException
-
nullsAreSortedLow
- Throws:
SQLException
-
othersDeletesAreVisible
- Throws:
SQLException
-
othersInsertsAreVisible
- Throws:
SQLException
-
othersUpdatesAreVisible
- Throws:
SQLException
-
ownDeletesAreVisible
- Throws:
SQLException
-
ownInsertsAreVisible
- Throws:
SQLException
-
ownUpdatesAreVisible
- Throws:
SQLException
-
storesLowerCaseIdentifiers
- Throws:
SQLException
-
storesLowerCaseQuotedIdentifiers
- Throws:
SQLException
-
storesMixedCaseIdentifiers
- Throws:
SQLException
-
storesMixedCaseQuotedIdentifiers
- Throws:
SQLException
-
storesUpperCaseIdentifiers
- Throws:
SQLException
-
storesUpperCaseQuotedIdentifiers
- Throws:
SQLException
-
supportsAlterTableWithAddColumn
- Throws:
SQLException
-
supportsAlterTableWithDropColumn
- Throws:
SQLException
-
supportsANSI92EntryLevelSQL
- Throws:
SQLException
-
supportsANSI92FullSQL
- Throws:
SQLException
-
supportsANSI92IntermediateSQL
- Throws:
SQLException
-
supportsBatchUpdates
- Throws:
SQLException
-
supportsCatalogsInDataManipulation
- Throws:
SQLException
-
supportsCatalogsInIndexDefinitions
- Throws:
SQLException
-
supportsCatalogsInPrivilegeDefinitions
- Throws:
SQLException
-
supportsCatalogsInProcedureCalls
- Throws:
SQLException
-
supportsCatalogsInTableDefinitions
- Throws:
SQLException
-
supportsColumnAliasing
- Throws:
SQLException
-
supportsConvert
- Throws:
SQLException
-
supportsCoreSQLGrammar
- Throws:
SQLException
-
supportsDataDefinitionAndDataManipulationTransactions
- Throws:
SQLException
-
supportsDataManipulationTransactionsOnly
- Throws:
SQLException
-
supportsDifferentTableCorrelationNames
- Throws:
SQLException
-
supportsExpressionsInOrderBy
- Throws:
SQLException
-
supportsExtendedSQLGrammar
- Throws:
SQLException
-
supportsFullOuterJoins
- Throws:
SQLException
-
supportsGetGeneratedKeys
- Throws:
SQLException
-
supportsGroupBy
- Throws:
SQLException
-
supportsGroupByBeyondSelect
- Throws:
SQLException
-
supportsIntegrityEnhancementFacility
- Throws:
SQLException
-
supportsLikeEscapeClause
- Throws:
SQLException
-
supportsLimitedOuterJoins
- Throws:
SQLException
-
supportsMinimumSQLGrammar
- Throws:
SQLException
-
supportsMixedCaseIdentifiers
- Throws:
SQLException
-
supportsMixedCaseQuotedIdentifiers
- Throws:
SQLException
-
supportsMultipleOpenResults
- Throws:
SQLException
-
supportsMultipleResultSets
- Throws:
SQLException
-
supportsMultipleTransactions
- Throws:
SQLException
-
supportsNamedParameters
- Throws:
SQLException
-
supportsNonNullableColumns
- Throws:
SQLException
-
supportsOpenCursorsAcrossCommit
- Throws:
SQLException
-
supportsOpenCursorsAcrossRollback
- Throws:
SQLException
-
supportsOpenStatementsAcrossCommit
- Throws:
SQLException
-
supportsOpenStatementsAcrossRollback
- Throws:
SQLException
-
supportsOuterJoins
- Throws:
SQLException
-
supportsPositionedDelete
- Throws:
SQLException
-
supportsPositionedUpdate
- Throws:
SQLException
-
supportsResultSetConcurrency
- Throws:
SQLException
-
supportsResultSetHoldability
- Throws:
SQLException
-
supportsResultSetType
- Throws:
SQLException
-
supportsSavepoints
- Throws:
SQLException
-
supportsSchemasInDataManipulation
- Throws:
SQLException
-
supportsSchemasInIndexDefinitions
- Throws:
SQLException
-
supportsSchemasInPrivilegeDefinitions
- Throws:
SQLException
-
supportsSchemasInProcedureCalls
- Throws:
SQLException
-
supportsSchemasInTableDefinitions
- Throws:
SQLException
-
supportsSelectForUpdate
- Throws:
SQLException
-
supportsStatementPooling
- Throws:
SQLException
-
supportsStoredFunctionsUsingCallSyntax
- Throws:
SQLException
-
supportsStoredProcedures
- Throws:
SQLException
-
supportsSubqueriesInComparisons
- Throws:
SQLException
-
supportsSubqueriesInExists
- Throws:
SQLException
-
supportsSubqueriesInIns
- Throws:
SQLException
-
supportsSubqueriesInQuantifieds
- Throws:
SQLException
-
supportsTableCorrelationNames
- Throws:
SQLException
-
supportsTransactionIsolationLevel
- Throws:
SQLException
-
supportsTransactions
- Throws:
SQLException
-
supportsUnion
- Throws:
SQLException
-
supportsUnionAll
- Throws:
SQLException
-
updatesAreDetected
- Throws:
SQLException
-
usesLocalFilePerTable
- Throws:
SQLException
-
usesLocalFiles
- Throws:
SQLException
-
isSet
private boolean isSet(int allModifiers, int requestedModifier) Return true if the requested modifer is set
-
unregisterFunction
Drop the function with this method name.
- Throws:
SQLException
-
registerFunction
Register the method as a Derby function.
- Throws:
SQLException
-
isTableFunction
Return true if the method describes a table function.
-
appendArgs
Append function arguments to an evolving ddl text buffer.
- Throws:
SQLException
-
appendReturnType
private void appendReturnType(StringBuffer buffer, Connection conn, Method method) throws SQLException Append return type to an evolving ddl text buffer
- Throws:
SQLException
-
appendTableFunctionSignature
private void appendTableFunctionSignature(StringBuffer buffer, Connection conn, Method method) throws SQLException Append the signature of a table function to an evolving ddl text buffer
- Throws:
SQLException
-
getDummyValue
Get a dummy value for an argument to a DBMD method.
-
stringifyJDBCType
private void stringifyJDBCType(StringBuffer buffer, ResultSetMetaData rsmd, int columnNumber) throws SQLException Append the name of a SQL type to an evolving ddl text buffer
- Throws:
SQLException
-
mapJavaToSQLType
Get the SQL type which corresponds to a Java type.
- Throws:
SQLException
-
getDBMD
Get the current session's database metadata.
- Throws:
SQLException
-
getDefaultConnection
Get the default connection, called from inside the database engine.
- Throws:
SQLException
-
executeDDL
Execute a DDL statement.
- Throws:
SQLException
-
prepareStatement
Prepare a statement and print out the text.
- Throws:
SQLException
-
wrap
Wrap an exception in a SQLException.
-