SolarMetric Kodo JDO 3.3.5 generated on August 31 2005

kodo.jdbc.schema
Class SchemaTool

java.lang.Object
  |
  +--kodo.jdbc.schema.SchemaTool

public class SchemaTool
extends Object

The SchemaTool is used to manage the database schema.


Field Summary
static String ACTION_ADD
           
static String ACTION_BUILD
           
static String ACTION_CREATEDB
           
static String ACTION_DROP
           
static String ACTION_DROPDB
           
static String ACTION_EXPORT
           
static String ACTION_IMPORT
           
static String ACTION_REFRESH
           
static String ACTION_RETAIN
           
static String[] ACTIONS
           
 
Constructor Summary
SchemaTool(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(Column col)
          Add the given column to the database schema.
 boolean addForeignKey(ForeignKey fk)
          Add the given foreign key to the database schema.
 boolean addPrimaryKey(PrimaryKey pk)
          Add the given primary key to the database schema.
 void build()
          Re-execute all SQL used for the creation of the current database; this action is usually used when creating SQL scripts.
 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(Index idx, Table table)
          Add the given index to the database schema.
 boolean createTable(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(Column col)
          Drop the given column from the database schema.
 void dropDB()
          Drop the current database.
 boolean dropForeignKey(ForeignKey fk)
          Drop the given foreign key from the database schema.
 boolean dropIndex(Index idx)
          Drop the given index from the database schema.
 boolean dropPrimaryKey(PrimaryKey pk)
          Drop the given primary key from the database schema.
 boolean dropTable(Table table)
          Drop the given table from the database schema.
 SchemaGroup getDBSchemaGroup()
          Return the database schema.
 boolean getDropTables()
          If true, tables that appear to be unused will be dropped.
 boolean getForeignKeys()
          Return whether foreign keys should be manipulated.
 boolean getIgnoreErrors()
          If true, SQLExceptions thrown during schema manipulation will be printed but ignored.
 boolean getIndexes()
          Return whether indexes should be manipulated.
 boolean getKodoTables()
          Whether to act on special tables used by Kodo components for bookkeeping.
 boolean getPrimaryKeys()
          Return whether primary keys should be generated.
 SchemaGroup getSchemaGroup()
          Return the schema group the tool will act on.
 PrintWriter getScriptWriter()
          The stream to write to for the creation of SQL scripts.
static void main(String[] args)
          Usage: java kodo.jdbc.schema.SchemaTool [option]* -action/-a <add | retain | drop | refresh | createDB | dropDB | build | 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(JDBCConfiguration conf, String[] args, serp.util.Options opts)
          Run the tool.
static boolean run(JDBCConfiguration conf, String action, String[] args, Writer scriptWriter, boolean dropTables, boolean ignoreErrors, boolean kodoTables, boolean pks, boolean fks, boolean indexes, boolean record, ClassLoader loader)
          Run the tool.
 void setDBSchemaGroup(SchemaGroup db)
          Set the database schema.
 void setDropTables(boolean dropTables)
          If true, tables that appear to be unused will be dropped.
 void setForeignKeys(boolean fks)
          Set whether foreign keys should be generated.
 void setIgnoreErrors(boolean ignoreErrs)
          If true, SQLExceptions thrown during schema manipulation will be printed but ignored.
 void setIndexes(boolean indexes)
          Set whether indexes should be manipulated.
 void setKodoTables(boolean kodoTables)
          Whether to act on special tables used by Kodo components for bookkeeping.
 void setPrimaryKeys(boolean pks)
          Set whether primary keys should be generated.
 void setSchemaGroup(SchemaGroup group)
          Set the schema group the tool will act on.
 void setScriptWriter(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 String ACTION_ADD

ACTION_DROP

public static final String ACTION_DROP

ACTION_RETAIN

public static final String ACTION_RETAIN

ACTION_REFRESH

public static final String ACTION_REFRESH

ACTION_BUILD

public static final String ACTION_BUILD

ACTION_CREATEDB

public static final String ACTION_CREATEDB

ACTION_DROPDB

public static final String ACTION_DROPDB

ACTION_IMPORT

public static final String ACTION_IMPORT

ACTION_EXPORT

public static final String ACTION_EXPORT

ACTIONS

public static final String[] ACTIONS
Constructor Detail

SchemaTool

public SchemaTool(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.

getKodoTables

public boolean getKodoTables()
Whether to act on special tables used by Kodo components for bookkeeping. Defaults to false.

setKodoTables

public void setKodoTables(boolean kodoTables)
Whether to act on special tables used by Kodo components for bookkeeping. Defaults to false.

getIndexes

public boolean getIndexes()
Return whether indexes should be manipulated. Defaults to true.

setIndexes

public void setIndexes(boolean indexes)
Set whether indexes should be manipulated. Defaults to true.

getForeignKeys

public boolean getForeignKeys()
Return whether foreign keys should be manipulated. Defaults to true.

setForeignKeys

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

getPrimaryKeys

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

setPrimaryKeys

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

getScriptWriter

public 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(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 SchemaGroup getSchemaGroup()
Return the schema group the tool will act on.

setSchemaGroup

public void setSchemaGroup(SchemaGroup group)
Set the schema group the tool will act on.

add

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

drop

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

retain

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

refresh

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

createDB

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

build

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

dropDB

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

record

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

createTable

public boolean createTable(Table table)
                    throws SQLException
Add the given table to the database schema.
Returns:
true if the operation was successful, false otherwise

dropTable

public boolean dropTable(Table table)
                  throws SQLException
Drop the given table from the database schema.
Returns:
true if the operation was successful, false otherwise

createIndex

public boolean createIndex(Index idx,
                           Table table)
                    throws SQLException
Add the given index to the database schema.
Returns:
true if the operation was successful, false otherwise

dropIndex

public boolean dropIndex(Index idx)
                  throws SQLException
Drop the given index from the database schema.
Returns:
true if the operation was successful, false otherwise

addColumn

public boolean addColumn(Column col)
                  throws SQLException
Add the given column to the database schema.
Returns:
true if the operation was successful, false otherwise

dropColumn

public boolean dropColumn(Column col)
                   throws SQLException
Drop the given column from the database schema.
Returns:
true if the operation was successful, false otherwise

addPrimaryKey

public boolean addPrimaryKey(PrimaryKey pk)
                      throws SQLException
Add the given primary key to the database schema.
Returns:
true if the operation was successful, false otherwise

dropPrimaryKey

public boolean dropPrimaryKey(PrimaryKey pk)
                       throws SQLException
Drop the given primary key from the database schema.
Returns:
true if the operation was successful, false otherwise

addForeignKey

public boolean addForeignKey(ForeignKey fk)
                      throws SQLException
Add the given foreign key to the database schema.
Returns:
true if the operation was successful, false otherwise

dropForeignKey

public boolean dropForeignKey(ForeignKey fk)
                       throws SQLException
Drop the given foreign key from the database schema.
Returns:
true if the operation was successful, false otherwise

getDBSchemaGroup

public SchemaGroup getDBSchemaGroup()
Return the database schema.

setDBSchemaGroup

public void setDBSchemaGroup(SchemaGroup db)
Set the database schema.

main

public static void main(String[] args)
                 throws IOException,
                        SQLException

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

Where the following options are recognized.

The various actions are as follows.

Examples:


run

public static boolean run(JDBCConfiguration conf,
                          String[] args,
                          serp.util.Options opts)
                   throws IOException,
                          SQLException
Run the tool. Returns false if any invalid options were given.
See Also:
main(java.lang.String[])

run

public static boolean run(JDBCConfiguration conf,
                          String action,
                          String[] args,
                          Writer scriptWriter,
                          boolean dropTables,
                          boolean ignoreErrors,
                          boolean kodoTables,
                          boolean pks,
                          boolean fks,
                          boolean indexes,
                          boolean record,
                          ClassLoader loader)
                   throws IOException,
                          SQLException
Run the tool. Return false if invalid options were given.

SolarMetric Kodo JDO 3.3.5 generated on August 31 2005

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