SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

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

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

public class SchemaTool
extends java.lang.Object

The SchemaTool is used to manage the database schema.


Field Summary
static java.lang.String ACTION_ADD
           
static java.lang.String ACTION_CREATEDB
           
static java.lang.String ACTION_DROP
           
static java.lang.String ACTION_DROPDB
           
static java.lang.String ACTION_EXPORT
           
static java.lang.String ACTION_IMPORT
           
static java.lang.String ACTION_REFRESH
           
static java.lang.String ACTION_RETAIN
           
 
Constructor Summary
SchemaTool(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
          Construct a SchemaTool that will use the given database.
 
Method Summary
 void add()
          Adds any components present in the schema repository but absent from the database.
 boolean addColumn(com.solarmetric.rd.kodo.impl.jdbc.schema.Column col)
          Add the given column to the database schema.
 boolean addForeignKey(com.solarmetric.rd.kodo.impl.jdbc.schema.ForeignKey fk)
          Add the given foreign key to the database schema.
 boolean addPrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.PrimaryKey pk)
          Add the given primary key to the database schema.
 void createDB()
          Re-execute all SQL used for the creation of the current database; this action is usually used when creating SQL scripts.
 boolean createIndex(com.solarmetric.rd.kodo.impl.jdbc.schema.Index idx)
          Add the given index to the database schema.
 boolean createTable(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table)
          Add the given table to the database schema.
 void drop()
          Drops all schema components in the schema repository that also exist in the database.
 boolean dropColumn(com.solarmetric.rd.kodo.impl.jdbc.schema.Column col)
          Drop the given column from the database schema.
 void dropDB()
          Drop the current database.
 boolean dropForeignKey(com.solarmetric.rd.kodo.impl.jdbc.schema.ForeignKey fk)
          Drop the given foreign key from the database schema.
 boolean dropIndex(com.solarmetric.rd.kodo.impl.jdbc.schema.Index idx)
          Drop the given index from the database schema.
 boolean dropPrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.PrimaryKey pk)
          Drop the given primary key from the database schema.
 boolean dropTable(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table)
          Drop the given table from the database schema.
 com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getDBSchemaGroup()
          Return the database schema.
 boolean getDropTables()
          If true, tables that appear to be unused will be dropped.
 boolean getIgnoreErrors()
          If true, SQLExceptions thrown during schema manipulation will be printed but ignored.
 com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
          Return the schema group the tool will act on.
 java.io.PrintWriter getScriptWriter()
          The stream to write to for the creation of SQL scripts.
static void main(java.lang.String[] args)
          Usage: java com.solarmetric.kodo.impl.schema.SchemaTool [option]* -action/-a <add | retain | drop | refresh | createDB | dropDB | import | export> <.schema file or resource>*
 void record()
          Record the changes made to the DB in the current SchemaFactory.
 void refresh()
          Adds any components present in the schema repository but absent from the database, and drops unused database components.
 void retain()
          Drops database components that are not mentioned in the schema repository.
static boolean run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf, java.lang.String action, java.lang.String[] args, java.io.Writer scriptWriter, boolean dropTables, boolean ignoreErrors, boolean record, java.lang.ClassLoader loader)
          Run the tool.
 void setDBSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup db)
          Set the database schema.
 void setDropTables(boolean dropTables)
          If true, tables that appear to be unused will be dropped.
 void setIgnoreErrors(boolean ignoreErrs)
          If true, SQLExceptions thrown during schema manipulation will be printed but ignored.
 void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup group)
          Set the schema group the tool will act on.
 void setScriptWriter(java.io.PrintWriter writer)
          The stream to write to for the creation of SQL scripts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_ADD

public static final java.lang.String ACTION_ADD
See Also:
Constant Field Values

ACTION_DROP

public static final java.lang.String ACTION_DROP
See Also:
Constant Field Values

ACTION_RETAIN

public static final java.lang.String ACTION_RETAIN
See Also:
Constant Field Values

ACTION_REFRESH

public static final java.lang.String ACTION_REFRESH
See Also:
Constant Field Values

ACTION_CREATEDB

public static final java.lang.String ACTION_CREATEDB
See Also:
Constant Field Values

ACTION_DROPDB

public static final java.lang.String ACTION_DROPDB
See Also:
Constant Field Values

ACTION_IMPORT

public static final java.lang.String ACTION_IMPORT
See Also:
Constant Field Values

ACTION_EXPORT

public static final java.lang.String ACTION_EXPORT
See Also:
Constant Field Values
Constructor Detail

SchemaTool

public SchemaTool(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf)
Construct a SchemaTool that will use the given database.

Method Detail

getIgnoreErrors

public boolean getIgnoreErrors()
If true, SQLExceptions thrown during schema manipulation will be printed but ignored.


setIgnoreErrors

public void setIgnoreErrors(boolean ignoreErrs)
If true, SQLExceptions thrown during schema manipulation will be printed but ignored.


getDropTables

public boolean getDropTables()
If true, tables that appear to be unused will be dropped. Defaults to false.


setDropTables

public void setDropTables(boolean dropTables)
If true, tables that appear to be unused will be dropped. Defaults to false.


getScriptWriter

public java.io.PrintWriter getScriptWriter()
The stream to write to for the creation of SQL scripts. If the stream is non-null, all SQL will be written to this stream rather than executed against the database.


setScriptWriter

public void setScriptWriter(java.io.PrintWriter writer)
The stream to write to for the creation of SQL scripts. If the stream is non-null, all SQL will be written to this stream rather than executed against the database.


getSchemaGroup

public com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getSchemaGroup()
Return the schema group the tool will act on.


setSchemaGroup

public void setSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup group)
Set the schema group the tool will act on.


add

public void add()
         throws java.sql.SQLException
Adds any components present in the schema repository but absent from the database.

java.sql.SQLException

drop

public void drop()
          throws java.sql.SQLException
Drops all schema components in the schema repository that also exist in the database.

java.sql.SQLException

retain

public void retain()
            throws java.sql.SQLException
Drops database components that are not mentioned in the schema repository.

java.sql.SQLException

refresh

public void refresh()
             throws java.sql.SQLException
Adds any components present in the schema repository but absent from the database, and drops unused database components.

java.sql.SQLException

createDB

public void createDB()
              throws java.sql.SQLException
Re-execute all SQL used for the creation of the current database; this action is usually used when creating SQL scripts.

java.sql.SQLException

dropDB

public void dropDB()
            throws java.sql.SQLException
Drop the current database.

java.sql.SQLException

record

public void record()
Record the changes made to the DB in the current SchemaFactory.


createTable

public boolean createTable(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table)
                    throws java.sql.SQLException
Add the given table to the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

dropTable

public boolean dropTable(com.solarmetric.rd.kodo.impl.jdbc.schema.Table table)
                  throws java.sql.SQLException
Drop the given table from the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

createIndex

public boolean createIndex(com.solarmetric.rd.kodo.impl.jdbc.schema.Index idx)
                    throws java.sql.SQLException
Add the given index to the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

dropIndex

public boolean dropIndex(com.solarmetric.rd.kodo.impl.jdbc.schema.Index idx)
                  throws java.sql.SQLException
Drop the given index from the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

addColumn

public boolean addColumn(com.solarmetric.rd.kodo.impl.jdbc.schema.Column col)
                  throws java.sql.SQLException
Add the given column to the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

dropColumn

public boolean dropColumn(com.solarmetric.rd.kodo.impl.jdbc.schema.Column col)
                   throws java.sql.SQLException
Drop the given column from the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

addPrimaryKey

public boolean addPrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.PrimaryKey pk)
                      throws java.sql.SQLException
Add the given primary key to the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

dropPrimaryKey

public boolean dropPrimaryKey(com.solarmetric.rd.kodo.impl.jdbc.schema.PrimaryKey pk)
                       throws java.sql.SQLException
Drop the given primary key from the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

addForeignKey

public boolean addForeignKey(com.solarmetric.rd.kodo.impl.jdbc.schema.ForeignKey fk)
                      throws java.sql.SQLException
Add the given foreign key to the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

dropForeignKey

public boolean dropForeignKey(com.solarmetric.rd.kodo.impl.jdbc.schema.ForeignKey fk)
                       throws java.sql.SQLException
Drop the given foreign key from the database schema.

Returns:
true if the operation was successful, false otherwise
java.sql.SQLException

getDBSchemaGroup

public com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup getDBSchemaGroup()
Return the database schema.


setDBSchemaGroup

public void setDBSchemaGroup(com.solarmetric.rd.kodo.impl.jdbc.schema.SchemaGroup db)
Set the database schema.


main

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

Usage: java com.solarmetric.kodo.impl.schema.SchemaTool [option]* -action/-a <add | retain | drop | refresh | createDB | dropDB | import | export> <.schema file or resource>*

Where the following options are recognized.

The various actions are as follows.

Examples:

java.io.IOException
java.sql.SQLException

run

public static boolean run(com.solarmetric.rd.kodo.impl.jdbc.conf.JDBCConfiguration conf,
                          java.lang.String action,
                          java.lang.String[] args,
                          java.io.Writer scriptWriter,
                          boolean dropTables,
                          boolean ignoreErrors,
                          boolean record,
                          java.lang.ClassLoader loader)
                   throws java.io.IOException,
                          java.sql.SQLException
Run the tool. Return false if invalid options were given.

java.io.IOException
java.sql.SQLException

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

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