public
Description: Java library for fetching and representing database metadata, with NetKernel support.
Clone URL: git://github.com/scharris/db-metadata.git
scharris (author)
Wed Jul 23 11:29:40 -0700 2008
commit  56bd5c5599e936b789359635b7e641203fc945b4
tree    09c41358f970e7663ffb1890496641ddbf12830f
parent  0d26bf88021c1e78b95f2a6b51901aa3df51c3bd
name age message
file .classpath Wed May 14 16:26:51 -0700 2008 Initial commit. [scharris]
file .gitignore Thu May 15 14:53:23 -0700 2008 Moved xml document creation into DBMetaData cla... [scharris]
file .project Wed May 14 16:26:51 -0700 2008 Initial commit. [scharris]
file COPYING Wed May 14 16:26:51 -0700 2008 Initial commit. [scharris]
file README Thu May 29 11:47:27 -0700 2008 Document standalone execution in README. [scharris]
file build.xml Wed Jul 23 11:20:10 -0700 2008 Updated jar archive. [scharris]
directory com/ Wed Jul 23 10:29:32 -0700 2008 Added support for single table metadata extract... [scharris]
file db-metadata.jar Wed Jul 23 11:20:10 -0700 2008 Updated jar archive. [scharris]
file entrypoints.xml Wed May 14 16:26:51 -0700 2008 Initial commit. [scharris]
file module.xml Wed Jul 23 11:29:40 -0700 2008 Added example output document. [scharris]
directory resources/ Wed Jul 23 11:29:40 -0700 2008 Added example output document. [scharris]
README
db-metadata: provides a simple java library and NetKernel module for fetching database metadata information.

As a Java Library: 
==================
  The db-metadata.jar archive may be used as a simple Java library for fetching metadata information for a 
database schema.  Use class com.github.scharris.db_metadata.DBMetaData to fetch metadata information about
tables, views, fields and foreign key links in a given schema.


As a NetKernel module:
======================
  The db-metadata.jar is also a valid self-contained NetKernel module which handles active:db-metadata 
uri requests.  

The metadata is returned in the following form:

<database-metadata  schema="..." identifiers-case-sensitivity="...">
    <relations>
      <relation type="..." id="..." name="..." schema="...">
        <field id="..." name="...">
          <type>
            <database-type/>
            <jdbc-type-code/>
            <jdbc-type-text/>
            [<max-chars/>]
            [<precision/>
             <scale/
             <radix/>]
          </type>
          <nullable/>
          [<primary-key-part/>]
        </field>
        ...
      </relation>   
      ...
    </relations>
        
    <foreign-key-links>
      <link>
        <referencing-relation name="..." schema="..."/>
        <referenced-relation name="..." schema="..."/>
        <match fk-field="..." pk-field="..."/>
        ...
      </link>
      ...
    </foreign-key-links>
</database-metadata>


Arguments for active:db-metadata requests in NetKernel
------------------------------------------------------
   +schema: either a direct schema name (not containing a ':'), or a uri which when sourced should return the
      schema name.  To enter a schema name containing a ':', use the "data:" scheme, e.g. "data:text/plain,ACCOUNTING".

   +views: whether to include views. 
    Valid values are y/yes/n/no/t/true/f/false or else a uri yielding one of these values.

   +tables: whether to include tables. 
    Valid values are as described for the views argument.

   +fields: whether to include field metadata within table and view elements.  
    Valid values are as described for the views argument.

   +fks: whether to include metadata describing foreign key links in the schema.
    Valid values are as described for the views argument.

Example uri:

  active:db-metadata+schema@myschema+views@ffcpl:/etc/include-views+fields@y+fks@y


NetKernel Module Installation:
------------------------------

  1) Copy the included db-metadata.jar file into your {NetKernel-Home}/modules directory, 
     or wherever else you'd like to keep it.
  2) Register the module's location with netkernel by entering its location in 
     {NetKernel-Home}/etc/deployedModules.xml, e.g. by adding a line like:
        <module>modules/db-metadata.jar</module>
  3) import the module into your own client modules:
      <import><uri>urn:com:github:scharris:db-metadata</uri></import>

Requests, suggestions and comments are welcome.  Send to steveOfAR at domain gmail.com.


As a Standalone Program
=======================
The DBMetaData class includes a main method which can write database metadata as xml to an output file.
To do this, first create a properties file describing the database connnection information, with properties:
jdbc-connect-url, jdbc-driver-class, user, and password.

For example,
#file connection.props
jdbc-connect-url=jdbc:oracle:thin:@myhost.mydomain.org:1528:mysid
jdbc-driver-class=oracle.jdbc.OracleDriver
user=mydbuser
password=mypassword

Then invoke the command like this:

  java -cp db-metadata.jar:ojdbc14.jar com.github.scharris.db_metadata.DBMetaData myschema connection.props myschema.xml

  
which would write the database metadata for schema myschema to file myschema.xml.