Class DBMDWrapper

java.lang.Object
org.apache.derby.impl.tools.optional.DBMDWrapper
All Implemented Interfaces:
OptionalTool

public class DBMDWrapper extends Object implements 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( '', '' );