IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.services.jdbcjournalservice
Class JDBCJournalSchemaGenerator

java.lang.Object
  extended bycom.ibm.btt.services.jdbcservicesinfra.JDBCServicesAdministrator
      extended bycom.ibm.btt.services.jdbcjournalservice.JDBCJournalSchemaGenerator

public class JDBCJournalSchemaGenerator
extends JDBCServicesAdministrator

The JDBCJournalSchemaGenerator class is responsible for creating, modifying, and removing all of the JDBCJournal Tables and the associated Control Tables.


Field Summary
 boolean createIndex
          Keeps the createIndex attribute value.
static boolean createSchema
          Keeps the createSchema attribute value.
 java.lang.String databaseName
          Keeps the databaseName attribute value.
 java.lang.String indexName
          Keeps the indexName attribute value.
static boolean recIdFromTable
          Keeps the recIdFromTable attribute value.
 int requestedNumberOfGenerations
          Keeps the number of generations for the journal schema.
 java.lang.String requestedTableDefinition
          Keeps the journal tables definition in SQL format.
static java.lang.String schemaName
          Keeps the journal schema name
static java.lang.String tableSpaceName
          Keeps the table space name where the electronic journal tables have to be created.
static boolean userDefaultSchema
          Keeps the userDefaultSchema attribute value.
 
Fields inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServicesAdministrator
COMPID, connMgrPool, databaseConnection, getSchemaSem
 
Constructor Summary
JDBCJournalSchemaGenerator()
          This constructor creates a JDBCJournalSchemaGenerator object.
JDBCJournalSchemaGenerator(java.lang.String aSchemaName)
          This constructor creates a JDBCJournalSchemaGenerator object for the specified schema.
 
Method Summary
 void addEntity(java.lang.String anEntityName)
          Adds a new entity in the journal schema definition.
 Vector allEntities()
          Returns a vector with the entities defined for the current journal schema.
static Vector allEntities(java.lang.String aSchemaName, boolean schemaInDatabase)
          Returns a Vector with the entities names defined for the journal schema aSchemaName.
protected static java.lang.String controlTableName(java.lang.String aSchemaName)
          Returns the name of the control table for the aSchemaName schema.
protected static DatabaseResultSetMetaData currentJournalTableColumnData(java.lang.String aSchemaName)
          Returns the DatabaseResultSetMetaData instance that contains column information for the journal table.
protected  java.lang.String currentJournalTableDefinition(java.lang.String aSchemaName)
          Calls the currentJournalTableColumnsData method to get the DatabaseResultSetMetaData instance for the aSchemaName schema.
 void generateSchema(Vector aListOfEntities, int nbrOfGenerations, java.lang.String aTableDefinition)
          Generates the journal schema with a schema name previously set or the default database schema name (set in the JournalConstants class in attribute DEFAULT_SCHEMA_NAME).
 void generateSchema(Vector aListOfEntities, int nbrOfGenerations, java.lang.String aTableDefinition, java.lang.String aSchemaName)
          Generates the journal schema with name aSchemaName in the currently connected database.
 java.lang.String getDatabaseName()
          Returns the databaseName attribute.
 java.lang.String getIndexName()
          Returns the indexName attribute.
protected static DatabaseResultSetMetaData getMetaData(java.lang.String aSchemaName, boolean schemaInDatabase)
          Returns the DatabaseResultSetMetaData instance associated with the schema aSchemaName.
 java.lang.String getSchemaName()
          Returns the schemaName attribute value.
 boolean isCreateIndex()
          Returns true if the application has requested to create indexes on the journal tables.
static boolean isRecIdFromTable()
          Returns the recIdFromTable.
 boolean isUserDefaultSchema()
          Returns true if the tables are going to be created in the default schema defined in the DBMS for the user requesting the database connection.
 java.lang.String journalTableDefinition()
          Returns a string with the SQL definition of the journal tables columns.
 int numberOfGenerations()
          Returns the number of journal generations in the journal service definition.
static int numberOfGenerations(java.lang.String aSchemaName, boolean schemaInDatabase)
          Returns the number of journal generations for the schema aSchemaName.
 void removeAllEntities(java.lang.String aSchemaName)
          Removes all entities for the given journal schema.
 void removeEntity(java.lang.String anEntityName)
          Removes anEntityName from the current journal schema.
 void removeEntity(java.lang.String anEntityName, java.lang.String aSchemaName)
          Removes the entity anEntityName from the journal schema aSchemaName.
 void removeSchema(java.lang.String aSchemaName)
          Removes a journal schema and all its related journal tables.
 void setCreateIndex(boolean newCreateIndex)
          Sets the createIndex attribute value to newCreateIndex.
 void setCreateSchema(boolean newCreateSchema)
          Sets the createSchema attribute value to newCreateSchema.
 void setDatabaseName(java.lang.String newDatabaseName)
          Sets the databaseName attribute value to newDatabaseName.
 void setIndexName(java.lang.String newIndexName)
          Sets the indexName attribute value to newIndexName.
static void setRecIdFromTable(boolean recIdFromTable)
          Sets the recIdFromTable.
 void setRequestedNumberOfGenerations(int newRequestedNumberOfGenerations)
          Sets the requestedNumberOfGenerations attribute value to newRequestedNumberOfGenerations.
 void setRequestedTableDefinition(java.lang.String newRequestedTableDefinition)
          Sets the requestedTableDefinition attribute value to newRequestedTableDefinition.
 void setSchemaName(java.lang.String newSchemaName)
          Sets the schemaName attribute value to newSchemaName.
 void setTableSpaceName(java.lang.String newTableSpaceName)
          Sets the tableSpace where journal tables have to be created.
 void setUserDefaultSchema(boolean newUserDefaultSchema)
          Sets the userDefaultSchema attribute value to newUserDefaultSchema.
protected static java.lang.String tableName(java.lang.String aSchemaName, java.lang.String anEntityName, java.lang.String aGeneration)
          Returns the current journal table name.
 
Methods inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServicesAdministrator
connect, connect, disconnect, dropProcedure, getConnectionManager, getProcedureMetaData, isRegistered, isRegistered, registerProcedure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestedNumberOfGenerations

public int requestedNumberOfGenerations
Keeps the number of generations for the journal schema.


requestedTableDefinition

public java.lang.String requestedTableDefinition
Keeps the journal tables definition in SQL format.


schemaName

public static java.lang.String schemaName
Keeps the journal schema name


createSchema

public static boolean createSchema
Keeps the createSchema attribute value. This attribute is set to true if the database schema representing the journal schema is to be created in the database by executing a CREATE SCHEMA statement. If this attribute is set to false, the database schema will not be created.


databaseName

public java.lang.String databaseName
Keeps the databaseName attribute value. This attribute is used when working with DB2 UDB in OS/390. In this environment, the database URL as set in the database connection has the following format: jdbc:db2os390:", where is the name of a shared database subsystem with different databases and storage groups defined in it. If not specified, the journal tables will be created in the default database within this location.


indexName

public java.lang.String indexName
Keeps the indexName attribute value. This attribute is used when working with DB2 UDB in OS/390. In this environment, when a table is created, also an index on that table must be created ( while in other operating systems a default index is automatically created). This attribute contains the index name to be used in the CREATE INDEX statement when creating the control table for the journal schema and the index name prefix to be used in the CREATE INDEX statement for all other journal tables. Default value is I.


createIndex

public boolean createIndex
Keeps the createIndex attribute value. This attribute is set to true if after the creation of the tables representing the journal unique indexes on the primary keys must be explicitly created, executing a CREATE UNIQUE INDEX statement. If this attribute is set to false, the indexes will not be created.


userDefaultSchema

public static boolean userDefaultSchema
Keeps the userDefaultSchema attribute value. When this attribute is set to true, the journal tables will be created in the default schema for the user that owns the connection to the database. No CREATE SCHEMA statement will be executed and the table name will not contain the schema name as prefix.


tableSpaceName

public static java.lang.String tableSpaceName
Keeps the table space name where the electronic journal tables have to be created. If null, tables will be created in the default table space.


recIdFromTable

public static boolean recIdFromTable
Keeps the recIdFromTable attribute value. When this attribute is set to true, the record id for the journal records will be kept in the journal control table and retrieved from there when required.

Constructor Detail

JDBCJournalSchemaGenerator

public JDBCJournalSchemaGenerator()
This constructor creates a JDBCJournalSchemaGenerator object.


JDBCJournalSchemaGenerator

public JDBCJournalSchemaGenerator(java.lang.String aSchemaName)
                           throws DSEInvalidArgumentException,
                                  DSEInvalidRequestException,
                                  DSEInternalErrorException,
                                  DSESQLException
This constructor creates a JDBCJournalSchemaGenerator object for the specified schema.

Parameters:
aSchemaName - java.lang.String the name of the Schema
Throws:
DSEInvalidArgumentException - if the Schema name is not valid
DSEInvalidRequestException - if the Schema already exists
DSEInternalErrorException - if an internal program error occurs
DSESQLException - when a SQL Exception is caught
Method Detail

addEntity

public void addEntity(java.lang.String anEntityName)
               throws DSESQLException,
                      DSEInvalidArgumentException,
                      DSEInternalErrorException,
                      DSEInvalidRequestException
Adds a new entity in the journal schema definition. If the entity already exists, it throws a DSEInvalidArgument exception.

Parameters:
anEntityName - java.lang.String the name of the entity to be added
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

allEntities

public Vector allEntities()
                   throws DSEInvalidRequestException,
                          DSEInternalErrorException,
                          DSESQLException
Returns a vector with the entities defined for the current journal schema.

Returns:
Vector the vector that contains all entities
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

allEntities

public static Vector allEntities(java.lang.String aSchemaName,
                                 boolean schemaInDatabase)
                          throws DSEInvalidRequestException,
                                 DSEInternalErrorException,
                                 DSESQLException
Returns a Vector with the entities names defined for the journal schema aSchemaName. It accesses the schema control table to get this information.

Parameters:
aSchemaName - java.lang.String the name of the journal schema
schemaInDatabase - java.lang.String indicates whether the schema was created in the database
Returns:
Vector - the vector that contains all entities
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

controlTableName

protected static java.lang.String controlTableName(java.lang.String aSchemaName)
Returns the name of the control table for the aSchemaName schema.

Parameters:
aSchemaName - java.lang.String the name of the journal schema

currentJournalTableColumnData

protected static DatabaseResultSetMetaData currentJournalTableColumnData(java.lang.String aSchemaName)
                                                                  throws DSEInternalErrorException,
                                                                         DSEInvalidRequestException,
                                                                         DSEInvalidArgumentException,
                                                                         DSESQLException
Returns the DatabaseResultSetMetaData instance that contains column information for the journal table. This method always requests the information from the database. The table name must be constructed by concatenating the schema name (available by default or provided as an argument), an entity name, and a generation number. The entity name is obtained by calling the allEntities method.

Parameters:
aSchemaName - java.lang.String the journal schema name
Returns:
DatabaseResultSetMetaData - the table meta data
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

currentJournalTableDefinition

protected java.lang.String currentJournalTableDefinition(java.lang.String aSchemaName)
                                                  throws DSEInvalidArgumentException,
                                                         DSEInvalidRequestException,
                                                         DSEInternalErrorException,
                                                         DSESQLException
Calls the currentJournalTableColumnsData method to get the DatabaseResultSetMetaData instance for the aSchemaName schema. From this information, it builds the string with the journal table columns definition.

Parameters:
aSchemaName - java.lang.String the journal schema Name
Returns:
java.lang.String - the journal tables definition for the specified schema name in SQL format
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

generateSchema

public void generateSchema(Vector aListOfEntities,
                           int nbrOfGenerations,
                           java.lang.String aTableDefinition)
                    throws DSEInvalidArgumentException,
                           DSEInvalidRequestException,
                           DSESQLException,
                           DSEInternalErrorException
Generates the journal schema with a schema name previously set or the default database schema name (set in the JournalConstants class in attribute DEFAULT_SCHEMA_NAME).

Parameters:
aListOfEntities - com.ibm.dse.base.Vector the vector of journal entities
nbrOfGenerations - int the number of journal generations
aTableDefinition - java.lang.String the table definition in SQL format
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

generateSchema

public void generateSchema(Vector aListOfEntities,
                           int nbrOfGenerations,
                           java.lang.String aTableDefinition,
                           java.lang.String aSchemaName)
                    throws DSEInvalidArgumentException,
                           DSEInvalidRequestException,
                           DSESQLException,
                           DSEInternalErrorException
Generates the journal schema with name aSchemaName in the currently connected database.

Parameters:
aListOfEntities - com.ibm.dse.base.Vector the vector of journal entities
nbrOfGenerations - int the number of journal generations
aTableDefinition - java.lang.String the table definition in SQL format
aSchemaName - java.lang.String the journal schema name
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

getDatabaseName

public java.lang.String getDatabaseName()
Returns the databaseName attribute. This method is used in the OS/390 environment to identify the database inside the location referenced by the database URL.

Returns:
java.lang.String

getIndexName

public java.lang.String getIndexName()
Returns the indexName attribute. This method is used in the OS/390 environment to create indexes on the journal achema tables.

Returns:
java.lang.String

getMetaData

protected static DatabaseResultSetMetaData getMetaData(java.lang.String aSchemaName,
                                                       boolean schemaInDatabase)
                                                throws DSEInvalidArgumentException,
                                                       DSEInvalidRequestException,
                                                       DSEInternalErrorException,
                                                       DSESQLException
Returns the DatabaseResultSetMetaData instance associated with the schema aSchemaName.

Parameters:
aSchemaName - java.lang.String the journal schema name
schemaInDatabase - java.lang.String indicates whether the schema was created in the database
Returns:
DatabaseResultSetMetaData the DatabaseResultSetMetaData (null if the key is not mapped to any value)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

getSchemaName

public java.lang.String getSchemaName()
Returns the schemaName attribute value.

Returns:
java.lang.String

isCreateIndex

public boolean isCreateIndex()
Returns true if the application has requested to create indexes on the journal tables. If false is returned, indexes are not explicitly created.


isUserDefaultSchema

public boolean isUserDefaultSchema()
Returns true if the tables are going to be created in the default schema defined in the DBMS for the user requesting the database connection. If set to false, the schema specified in attribute schemaName is used.


journalTableDefinition

public java.lang.String journalTableDefinition()
                                        throws DSEException
Returns a string with the SQL definition of the journal tables columns.

Returns:
java.lang.String
Throws:
DSEException - if a DSEException occurs

numberOfGenerations

public int numberOfGenerations()
                        throws DSEInvalidRequestException,
                               DSESQLException,
                               DSEInternalErrorException
Returns the number of journal generations in the journal service definition.

Returns:
int
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

numberOfGenerations

public static int numberOfGenerations(java.lang.String aSchemaName,
                                      boolean schemaInDatabase)
                               throws DSEInvalidRequestException,
                                      DSESQLException,
                                      DSEInternalErrorException
Returns the number of journal generations for the schema aSchemaName.

Parameters:
aSchemaName - java.lang.String the journal schema name
schemaInDatabase - java.lang.String indicates whether the schema was created in the database
Returns:
int
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

removeAllEntities

public void removeAllEntities(java.lang.String aSchemaName)
                       throws DSEInvalidArgumentException,
                              DSEInvalidRequestException,
                              DSEInternalErrorException,
                              DSESQLException
Removes all entities for the given journal schema. NOTE: this method should leave the special row with the DSEJOU entity name.

Parameters:
aSchemaName - java.lang.String the name of the journal schema
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

removeEntity

public void removeEntity(java.lang.String anEntityName)
                  throws DSEInternalErrorException,
                         DSEInvalidArgumentException,
                         DSEInvalidRequestException,
                         DSESQLException
Removes anEntityName from the current journal schema.

Parameters:
anEntityName - java.lang.String the entity name
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

removeEntity

public void removeEntity(java.lang.String anEntityName,
                         java.lang.String aSchemaName)
                  throws DSEInvalidArgumentException,
                         DSEInvalidRequestException,
                         DSEInternalErrorException,
                         DSESQLException
Removes the entity anEntityName from the journal schema aSchemaName.

Parameters:
anEntityName - java.lang.String the entity name
aSchemaName - java.lang.String the journal schema name
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

removeSchema

public void removeSchema(java.lang.String aSchemaName)
                  throws DSEInvalidRequestException,
                         DSEInvalidArgumentException,
                         DSEInternalErrorException,
                         DSESQLException
Removes a journal schema and all its related journal tables.

Parameters:
aSchemaName - java.lang.String the name of the journal schema
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

setCreateIndex

public void setCreateIndex(boolean newCreateIndex)
Sets the createIndex attribute value to newCreateIndex.

Parameters:
newCreateIndex - boolean

setCreateSchema

public void setCreateSchema(boolean newCreateSchema)
Sets the createSchema attribute value to newCreateSchema.

Parameters:
newCreateSchema - boolean

setDatabaseName

public void setDatabaseName(java.lang.String newDatabaseName)
Sets the databaseName attribute value to newDatabaseName.

Parameters:
newDatabaseName - java.lang.String

setIndexName

public void setIndexName(java.lang.String newIndexName)
Sets the indexName attribute value to newIndexName.

Parameters:
newIndexName - java.lang.String

setRequestedNumberOfGenerations

public void setRequestedNumberOfGenerations(int newRequestedNumberOfGenerations)
Sets the requestedNumberOfGenerations attribute value to newRequestedNumberOfGenerations.

Parameters:
newRequestedNumberOfGenerations - int

setRequestedTableDefinition

public void setRequestedTableDefinition(java.lang.String newRequestedTableDefinition)
Sets the requestedTableDefinition attribute value to newRequestedTableDefinition.

Parameters:
newRequestedTableDefinition - java.lang.String

setSchemaName

public void setSchemaName(java.lang.String newSchemaName)
Sets the schemaName attribute value to newSchemaName.

Parameters:
newSchemaName - java.lang.String

setUserDefaultSchema

public void setUserDefaultSchema(boolean newUserDefaultSchema)
Sets the userDefaultSchema attribute value to newUserDefaultSchema.

Parameters:
newUserDefaultSchema - boolean

setTableSpaceName

public void setTableSpaceName(java.lang.String newTableSpaceName)
Sets the tableSpace where journal tables have to be created.

Parameters:
newTableSpaceName - String

tableName

protected static java.lang.String tableName(java.lang.String aSchemaName,
                                            java.lang.String anEntityName,
                                            java.lang.String aGeneration)
Returns the current journal table name.

Parameters:
aSchemaName - java.lang.String the journal schema name
anEntityName - java.lang.String the entity name
aGeneration - java.lang.String the journal generation
Returns:
java.lang.String - the full table name

isRecIdFromTable

public static boolean isRecIdFromTable()
Returns the recIdFromTable.

Returns:
boolean

setRecIdFromTable

public static void setRecIdFromTable(boolean recIdFromTable)
Sets the recIdFromTable.

Parameters:
recIdFromTable - The recIdFromTable to set

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005