SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.kodo.impl.jdbc.schema
Class SchemaGenerator

java.lang.Object
  |
  +--com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGenerator

public class SchemaGenerator
extends java.lang.Object

The SchemaGenerator creates Schemas matching the current database. All schemas are added to the current SchemaGroup.

Note that tables whose name starts with "JDO" will be not be added to the database schema. This enables the creation of special tables that will never be dropped by the SchemaTool.


Constructor Summary
SchemaGenerator(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
          Constructor.
 
Method Summary
 void generateForeignKeys(java.lang.String schemaName)
          Generate foreign key information for the given schema.
 void generateForeignKeys(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table, java.sql.Connection conn, java.sql.DatabaseMetaData meta)
          Generates table foreign keys.
 void generateIndexes(java.lang.String schemaName)
          Generate index information for the given schema.
 void generateIndexes(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table, java.sql.Connection conn, java.sql.DatabaseMetaData meta)
          Generates table indexes.
 void generatePrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table, java.sql.Connection conn, java.sql.DatabaseMetaData meta)
          Generates table primary keys.
 void generatePrimaryKeys(java.lang.String schemaName)
          Generate primary key information for the given schema.
 void generateSchema(java.lang.String name, java.lang.String[] tableNames)
          Add a fully-constructed Schema matching the given database schema to the current group.
 void generateSchemas()
          Generate all schemas set in the configuration.
 void generateSchemas(java.lang.String[] schemasAndTables)
          Generate the schemas and/or tables named in the given strings.
 void generateTables(java.lang.String schemaName, java.lang.String tableName, java.sql.Connection conn, java.sql.DatabaseMetaData meta)
          Adds all tables matching the given name pattern to the schema.
 boolean getGenerateForeignKeys()
          Return whether foreign keys should be generated.
 boolean getGenerateIndexes()
          Return whether indexes should be generated.
 boolean getGeneratePrimaryKeys()
          Return whether primary keys should be generated.
 com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
          Return the current schema group.
static void main(java.lang.String[] args)
          Usage: java com.solarmetric.kodo.impl.schema.SchemaGenerator [option]*
static void run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf, boolean pks, boolean indexes, boolean fks, java.io.Writer out)
          Run the tool.
 void setGenerateForeignKeys(boolean fks)
          Set whether foreign keys should be generated.
 void setGenerateIndexes(boolean indexes)
          Set whether indexes should be generated.
 void setGeneratePrimaryKeys(boolean pks)
          Set whether primary keys should be generated.
 void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup group)
          Set the schema group to add generated schemas to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaGenerator

public SchemaGenerator(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
Constructor.

Parameters:
conf - configuration for connecting to the data store
Method Detail

getGenerateIndexes

public boolean getGenerateIndexes()
Return whether indexes should be generated. Defaults to true.


setGenerateIndexes

public void setGenerateIndexes(boolean indexes)
Set whether indexes should be generated. Defaults to true.


getGenerateForeignKeys

public boolean getGenerateForeignKeys()
Return whether foreign keys should be generated. Defaults to true.


setGenerateForeignKeys

public void setGenerateForeignKeys(boolean fks)
Set whether foreign keys should be generated. Defaults to true.


getGeneratePrimaryKeys

public boolean getGeneratePrimaryKeys()
Return whether primary keys should be generated. Defaults to true.


setGeneratePrimaryKeys

public void setGeneratePrimaryKeys(boolean pks)
Set whether primary keys should be generated. Defaults to true.


getSchemaGroup

public com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
Return the current schema group.


setSchemaGroup

public void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup group)
Set the schema group to add generated schemas to.


generateSchemas

public void generateSchemas()
                     throws java.sql.SQLException
Generate all schemas set in the configuration. This method also calls generateIndexes(java.lang.String), generatePrimaryKeys(java.lang.String), and generateForeignKeys(java.lang.String) automatically.

java.sql.SQLException

generateSchemas

public void generateSchemas(java.lang.String[] schemasAndTables)
                     throws java.sql.SQLException
Generate the schemas and/or tables named in the given strings. See the main(java.lang.String[]) method description for how to specify schema and table names. This method calls generateIndexes(java.lang.String), generatePrimaryKeys(java.lang.String), and generateForeignKeys(java.lang.String) automatically.

java.sql.SQLException

generateSchema

public void generateSchema(java.lang.String name,
                           java.lang.String[] tableNames)
                    throws java.sql.SQLException
Add a fully-constructed Schema matching the given database schema to the current group. No foreign keys are generated because some keys might span schemas. You must call generatePrimaryKeys(java.lang.String), generateIndexes(java.lang.String), and generateForeignKeys(java.lang.String) separately.

Parameters:
name - the database name of the schema, or null for all schemas
java.sql.SQLException

generatePrimaryKeys

public void generatePrimaryKeys(java.lang.String schemaName)
                         throws java.sql.SQLException
Generate primary key information for the given schema. This method must be called in addition to generateSchema(java.lang.String, java.lang.String[]). It should only be called after all schemas are generated. The schema name can be null to indicate that indexes should be generated for all schemas.

java.sql.SQLException

generateIndexes

public void generateIndexes(java.lang.String schemaName)
                     throws java.sql.SQLException
Generate index information for the given schema. This method must be called in addition to generateSchema(java.lang.String, java.lang.String[]). It should only be called after all schemas are generated. The schema name can be null to indicate that indexes should be generated for all schemas.

java.sql.SQLException

generateForeignKeys

public void generateForeignKeys(java.lang.String schemaName)
                         throws java.sql.SQLException
Generate foreign key information for the given schema. This method must be called in addition to generateSchema(java.lang.String, java.lang.String[]). It should only be called after all schemas that are linked via foreign keys are generated. The schema name given can be null to indicate that foreign keys should be generated for all schemas.

java.sql.SQLException

generateTables

public void generateTables(java.lang.String schemaName,
                           java.lang.String tableName,
                           java.sql.Connection conn,
                           java.sql.DatabaseMetaData meta)
                    throws java.sql.SQLException
Adds all tables matching the given name pattern to the schema.

java.sql.SQLException

generatePrimaryKey

public void generatePrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table,
                               java.sql.Connection conn,
                               java.sql.DatabaseMetaData meta)
                        throws java.sql.SQLException
Generates table primary keys.

java.sql.SQLException

generateIndexes

public void generateIndexes(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table,
                            java.sql.Connection conn,
                            java.sql.DatabaseMetaData meta)
                     throws java.sql.SQLException
Generates table indexes.

java.sql.SQLException

generateForeignKeys

public void generateForeignKeys(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table,
                                java.sql.Connection conn,
                                java.sql.DatabaseMetaData meta)
                         throws java.sql.SQLException
Generates table foreign keys.

java.sql.SQLException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.sql.SQLException

Usage: java com.solarmetric.kodo.impl.schema.SchemaGenerator [option]*

Where the following options are recognized.

You can use the -schemas argument to give a comma- separated list of schemas and tables to generate. All table names must be of the form <schema>.<table>. If the table's schema is unknown or null, specify the table name with a preceding period: .<table>. If a schema name is given but no tables are listed for that schema, all tables in the shcema will be generated. If no arguments at all are given, all tables of all schemas listed in the JDBCConfiguration will be generated.

java.io.IOException
java.sql.SQLException

run

public static void run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf,
                       boolean pks,
                       boolean indexes,
                       boolean fks,
                       java.io.Writer out)
                throws java.io.IOException,
                       java.sql.SQLException
Run the tool.

java.io.IOException
java.sql.SQLException

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.