Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.2.4 generated on January 7 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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.

  - -properties/-p <properties file or resource>: The path or resource name of a Kodo properties file containing information such as the license key and connection data as outlined in `JDBCConfiguration`. Optional.
  - -<property name> <property value>: All bean properties of the Kodo `JDBCConfiguration` can be set by using their names and supplying a value. For example: `-licenseKey adslfja83r3lkadf`
  - -ignoreErrors/-i <true/t | false/f>: If false, an exception will will be thrown if the tool encounters any database exceptions; defaults to `false`.
  - -file/-f <stdout | output file or resource>: Use this option to write a SQL script for the planned schema modifications, rather than committing them to the database. This option also applies to the `export` action.
  - -dropTables/-dt <true/t | false/f>: Set this option to true to drop tables that appear to be unused during `retain` and `refresh` actions. Defaults to `true`.
  - -primaryKeys/-pk <true/t | false/f>: Whether primary keys are manipulated. Defaults to true.
  - -foreignKeys/-fk <true/t | false/f>: Whether foreign keys are manipulated. Defaults to true.
  - -indexes/-ix <true/t | false/f>: Whether indexes are manipulated. Defaults to true.
  - -record/-r <true/t | false/f>: Set this option to `false` to prevent writing the schema changes to the current `SchemaFactory`.

  The various actions are as follows.

  - add: Bring the schema up-to-date with the latest changes to the schema XML data by adding tables, columns, indexes, etc. This action never drops any data.
  - retain: Keep all schema components in the schema XML, but drop the rest from the database. This action never adds any data.
  - drop: Drop all the schema components in the schema XML.
  - refresh: Equivalent to retain, then add.
  - createDB: Execute SQL to re-create the current database. This action is typically used in conjuction with the `file` option.
  - build: Execute SQL to build the schema defined in the XML. Because it doesn't take the current database schema into account, this action is typically used in conjuction with the `file` option.
  - dropDB: Execute SQL to drop the current database. This action implies `dropTables`.
  - import: Import the given XML schema definition into the current `SchemaFactory`.
  - export: Export the current `SchemaFactory`'s recorded schema to an XML schema definition file.

  Examples:

  - Write a script to stdout to re-create the current database schema:
    `java kodo.jdbc.schema.SchemaTool -file stdout -action createDB`
  - Drop the current database schema:
    `java kodo.jdbc.schema.SchemaTool -action dropDB`
  - Create a schema based on an XML schema definition file:
    `java kodo.jdbc.schema.SchemaTool -action add myschema.xml`

### 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.2.4 generated on January 7 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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