Top Description Fields Constructors Methods
org.apache.derby.impl.tools.optional

public Class DBMDWrapper

extends Object
implements OptionalTool
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.dictionary.OptionalTool
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier, java.sql.Connection, .DriverManager, .DatabaseMetaData, .PreparedStatement, .ResultSet, .ResultSetMetaData, .SQLException, .Types, org.apache.derby.iapi.sql.dictionary.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:

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

Modifier and TypeField and Description
private static final int

Constructor Summary

AccessConstructor and Description
public
DBMDWrapper()

0-arg constructor to satisfy the OptionalTool contract

Method Summary

Modifier and TypeMethod and Description
public static boolean
public 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 buffer

private void
appendTableFunctionSignature(StringBuffer buffer, Connection conn, Method method)

Append the signature of a table function to an evolving ddl text buffer

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
private static void
executeDDL(Connection conn, String text)

Execute a DDL statement.

public static ResultSet
getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern)

public static ResultSet
getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)

public static ResultSet
public static String
public static String
public static ResultSet
public static ResultSet
getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)

public static ResultSet
getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)

public static ResultSet
getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable)

public static int
public static int
public static String
public static String
private static DatabaseMetaData
getDBMD()

Get the current session's database metadata.

private static Connection
getDefaultConnection()

Get the default connection, called from inside the database engine.

public static int
public static int
public static int
public static String
public static String
private Object
getDummyValue(Class<T> type)

Get a dummy value for an argument to a DBMD method.

public static ResultSet
getExportedKeys(String catalog, String schema, String table)

public static String
public static ResultSet
getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern)

public static ResultSet
getFunctions(String catalog, String schemaPattern, String functionNamePattern)

public static String
public static ResultSet
getImportedKeys(String catalog, String schema, String table)

public static ResultSet
getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)

public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static int
public static String
public static ResultSet
getPrimaryKeys(String catalog, String schema, String table)

public static ResultSet
getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern)

public static ResultSet
getProcedures(String catalog, String schemaPattern, String procedureNamePattern)

public static String
public static int
public static ResultSet
getSchemas(String catalog, String schemaPattern)

public static String
public static String
public static String
public static int
public static String
public static ResultSet
getSuperTables(String catalog, String schemaPattern, String tableNamePattern)

public static ResultSet
getSuperTypes(String catalog, String schemaPattern, String typeNamePattern)

public static String
public static ResultSet
getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern)

public static ResultSet
getTables(String catalog, String schemaPattern, String tableNamePattern)

public static ResultSet
public static String
public static ResultSet
public static ResultSet
getUDTs(String catalog, String schemaPattern, String typeNamePattern)

public static String
public static String
public static ResultSet
getVersionColumns(String catalog, String schema, String table)

public static boolean
public static boolean
public static boolean
private boolean
isSet(int allModifiers, int requestedModifier)

Return true if the requested modifer is set

private boolean
isTableFunction(Method method)

Return true if the method describes a table function.

public void
loadTool(String... configurationParameters)

Implements org.apache.derby.iapi.sql.dictionary.OptionalTool.loadTool.

Load the tool, giving it optional configuration parameters
public static boolean
private String
mapJavaToSQLType(Class<T> javaType)

Get the SQL type which corresponds to a Java type.

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
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.

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
private void
stringifyJDBCType(StringBuffer buffer, ResultSetMetaData rsmd, int columnNumber)

Append the name of a SQL type to an evolving ddl text buffer

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
supportsConvert(int fromType, int toType)

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
supportsResultSetConcurrency(int type, int concurrency)

public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public static boolean
public void
unloadTool(String... configurationParameters)

Implements org.apache.derby.iapi.sql.dictionary.OptionalTool.unloadTool.

Unload the tool, giving it optional configuration parameters
private void
unregisterFunction(Connection conn, Method method)

Drop the function with this method name.

public static boolean
public static boolean
public static boolean
private static SQLException
wrap(Throwable t)

Wrap an exception in a SQLException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait