IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.services.jdbcjournalservice
Class JDBCJournalImpl

java.lang.Object
  extended bycom.ibm.btt.base.Service
      extended bycom.ibm.btt.services.BTTServiceImpl
          extended bycom.ibm.btt.services.PoolableServiceImpl
              extended bycom.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
                  extended bycom.ibm.btt.services.jdbcjournalservice.JournalImpl
                      extended bycom.ibm.btt.services.jdbcjournalservice.JDBCJournalImpl
All Implemented Interfaces:
BTTService, DatabaseConnect, Externalizable, java.io.Externalizable, JournalService, Poolable, java.io.Serializable

public class JDBCJournalImpl
extends JournalImpl
implements JournalService

The JDBCJournalImpl class is a concrete class that represents a Financial Electronic Journal to provide an implementation of the JournalImpl abstraction. The JDBCJournal uses the JDBC interface to access the database and can be used with any DBMS providing an implementation of this interface.

See Also:
Serialized Form

Field Summary
protected  Hashtable columnsTable
          Contains information about the relationship between a column in the database table and a data field in the context.
protected  boolean createSchema
          Keeps whether the journal schema was also created in the database or not.
protected  java.lang.String date
          Keeps the today date
protected  int lastRecordNumberFromTable
           
protected static java.lang.Object poolSem
           
protected static java.lang.Object resetSem
           
protected  java.lang.String schemaName
          Keeps the name of the schema where all journal tables are defined.
protected static boolean singleTableReset
           
protected  java.lang.String tableName
          Keeps the table name that is schemaName.entity_wrapNumber.
protected static java.lang.String var_insert
           
protected static java.lang.String var_update
           
protected static java.lang.String var_where
           
protected  int wrapNumber
          Keeps the number of the generation being used by the current journal.
 
Fields inherited from class com.ibm.btt.services.jdbcjournalservice.JournalImpl
COMPID, currentSingleTableReset, entity, fromPool, lastRecordNumber, recIdFromTable, recIdSem, singleTable, singleTableLastRecordNumber
 
Fields inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
addPstmt, addString, autoCommit, connectionProperties, databaseConnection, databaseURL, dataSourceName, metaData, operationtime, password, poolName, sharedConnection, STMT_POOL_SIZE_DEFAULT, stmtPool, stmtPoolSize, updateString, user, waitRetry
 
Fields inherited from class com.ibm.btt.services.BTTServiceImpl
DEFAULT_RESPONSE
 
Fields inherited from class com.ibm.btt.base.Service
externalizer, name
 
Constructor Summary
JDBCJournalImpl()
          This constructor creates a JDBCJournal object.
JDBCJournalImpl(java.lang.String anEntityName, java.lang.String aSchemaName)
          This constructor creates a JDBCJournal object.
 
Method Summary
 int addRecord(Hashtable aDataHashtable)
          Inserts the data in aDataHashtable as a new row in the current journal table.
protected  void buildAddString()
          Builds an instance variable that is used when adding a record.
protected  void buildConnectionProperties()
          Builds the hashtable containing all details needed to request the database connection.
protected  void buildUpdateString()
          Builds an instance variable that is used when updating all columns of a record.
 void commit()
          Commits all changes to the database.
 void connect(java.lang.String anUser, java.lang.String aPassword)
          Connects to the Database set in the DataSource definition, with user identification aUser and password aPassword.
protected  java.lang.String controlTableName()
          Returns the current Control Table name.
 java.lang.String currentGenerationDate()
          Returns the last date that the journal service was used by a specific entity.
protected  int currentWrapNumber()
          Returns the current table generation number being used by the journal instance for the schema set in the schemaName attribute.
protected  int currentWrapNumberForSchema(java.lang.String aSchemaName)
          Returns the current table generation number being used by the journal instance for the schema aSchemaName.
protected  void deleteJournalContent(int aGeneration)
          Deletes the contents of a current journal table.
protected  void deleteRecord(int aRecordNumber)
          Deletes a record in the current journal table.
 void disconnect()
          Closes the Database connection.
 Hashtable getColumnsTable()
          Returns the columnsTable attribute value of the current journal.
protected  java.sql.Connection getDatabaseConnection()
          Returns the databaseConnection attribute value.
 Vector getEntities()
          Retrieves all entities from the Database.
 int getLastRecordNumberFromTable()
          Returns the lastRecordNumber from control table.
 int getNumberOfGenerations()
          Returns the number of journal generations.
 java.lang.String getSchemaName()
          Returns the schemaName attribute value.
 java.lang.String getTableName()
          Returns the current journal tableName.
protected  int getWrapNumber()
          Returns the wrapNumber attribute value
 java.lang.Object handleCommand(java.lang.String opName, java.util.Hashtable requestParam)
          handleCommand just pass parameter to service, and let the service object execute operation
 java.lang.Object initializeColumnFrom(Tag aTag)
          Used by the JDBCJournal service externalizer to create the contents of the columnsTable instance attribute.
 java.lang.Object initializeFrom(Tag aTag)
          Used by the services externalizer to set the JDBCJournal instance attributes as defined in the XML file.
 boolean isConnected()
          Returns true if there is a connection to the database or false if there is not.
 boolean isCreateSchema()
          Returns the createSchema property value.
static boolean isSingleTableReset()
          Returns the singleTableReset.
 boolean isValidEntity()
          Returns true if the entity set for the current journal is valid or false if it is not.
protected  java.lang.String journalTableRowInsertDefinition()
          Returns the Journal Table Row definition for an SQL INSERT request.
static JDBCJournalImpl newFor(java.lang.String anEntityName, java.lang.String aSchemaName)
          Returns a new JDBCJournal instance with the entityName and schemaName attributes set to the provided values.
protected  int nextWrapNumber()
          Returns the next generation number to be used for the default schema.
protected  int nextWrapNumberForSchema(java.lang.String aSchemaName)
          Returns the next generation number available for the specified schema.
 void open(java.lang.String anEntity, int aGeneration)
          Opens the journal service with an entity and a generation number
 void open(java.lang.String aSchemaName, java.lang.String anEntity, int aGeneration)
          Opens the journal service with a specific shema, an entity, and a generation number.
 void openForEntity(java.lang.String anEntity)
          Opens the current journal table for anEntity.
 void openForEntity(java.lang.String anEntity, java.lang.String aSchemaName)
          Decides which is going to be the current journal table for anEntity.
 void openForSchema(java.lang.String aSchemaName)
          Decides which is going to be the current journal table.
 void openOnCurrentTable()
          Selects the already selected table generation for the current schema as the current journal table.
 void openOnCurrentTableForSchema(java.lang.String aSchemaName)
          Selects the already selected table generation for the specified schema as the current journal table.
 void openOnNextTable()
          Selects the next available table generation for the current schema as the current journal table.
 void openOnNextTableForSchema(java.lang.String aSchemaName)
          Selects the next available table generation for the specified schema as the current journal table.
 int queryLastRecordNumber()
          Returns the last record number in the current journal table.
protected  Vector recordToRow(Hashtable aDataHashtable)
          Returns a list of ordered data field values.
 void resetSingleTableLastRecordNumber()
          Resets the Journal last record number when different instances are accessing the same tables
 Hashtable retrieveLastRecord()
          Retrieves the last record of the current journal table.
 Vector retrieveLastRecords(int aNumber)
          Returns a vector with aNumber or any number between 0 and aNumber of record Hashtables.
 Hashtable retrieveRecord(int aRecordNumber)
          Retrieves the record with the record identification in the database equal to aRecordNumber.
 Vector retrieveRecords(java.lang.String aSearchCondition)
          Retrieves all the records within the current journal that match aSearchCondition.
 Vector retrieveRecords(java.lang.String aSearchCondition, Vector aColumnsVector)
          Retrieves the columns in aColumnsVector of all the records within the current journal that match aSearchCondition.
 void rollback()
          Rolls back all database changes.
protected  void setColumnsTable(Hashtable aColumnsHashtable)
          Sets the columnsTable property to aColumnsHashtable value.
 void setCreateSchema(boolean newCreateSchema)
          Sets the createSchema property to newCreateSchema.
protected  void setDatabaseConnection(java.sql.Connection aDatabaseConnection)
          Sets the database connection property to aDatabaseConnection.
 void setEntity(java.lang.String anEntityName)
          Sets the entity property value to anEntityName.
 void setLastRecordNumberFromTable(int aLastRecordNumberFromTable)
          Sets the lastRecordNumberFromTable into control table.
 void setSchemaName(java.lang.String aSchemaName)
          Sets the schemaName property to aSchemaName
static void setSingleTableReset(boolean singleTableReset)
          Sets the singleTableReset.
protected  void setTableName(java.lang.String aTableName)
          Sets the tableName.
protected  java.lang.String tableName(java.lang.String aSchemaName, java.lang.String anEntityName, int aGeneration)
          Returns the journal table name for a specific schema name, entity name and generation.
 Vector toStrings()
          Used by the Db2Journal service externalizer.
 int updateLastRecord(Hashtable aDataHashtable)
          Updates the last record of the current journal table with the data in aDataHashtable.
 int updateLastRecord(Hashtable aDataHashtable, Vector aColumnsVector)
          Updates the columns in aColumnsVector for the last record of the current journal table with the data in aDataHashtable.
 int updateRecord(int aRecordNumber, Hashtable aDataHashtable)
          Updates the record identified by aRecordNumber within the journal table with the data provided in aDataHashtable by calling the updateRecords(String, Hashtable) method.
 int updateRecord(int aRecordNumber, Hashtable aDataHashtable, Vector aColumnsVector)
          Updates the columns specified in aColumnsVector, for the record identified by aRecordNumber within the journal table, with the data provided in aDataHashtable.
 int updateRecords(java.lang.String aSearchCondition, Hashtable aDataHashtable)
          Updates all the current journal table records that match the search condition with the aDataHashtable data.
 int updateRecords(java.lang.String aSearchCondition, Hashtable aDataHashtable, Vector aColumnsVector)
          Updates the columns specified in aColumnsVector with the data provided in aDataHashtable for the records matching the search condition within the journal table.
 
Methods inherited from class com.ibm.btt.services.jdbcjournalservice.JournalImpl
close, getDate, getEntity, getInUse, getLastRecordNumber, getSingleTableLastRecordNumber, getState, initialize, isActive, isCurrentSingleTableReset, isFromPool, isRecIdFromTable, isSingleTable, open, reset, setCurrentSingleTableReset, setFromPool, setInUse, setLastRecordNumber, setRecIdFromTable, setSingleTable, setSingleTableLastRecordNumber, setState, terminate, today
 
Methods inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
buildStatementArray, connect, getAddPstmt, getAddString, getAutoCommit, getConnectionManager, getConnectionProperties, getConnMgrID, getDataSourceName, getPassword, getUpdateString, getUser, isWaitRetry, requestConnectionToConnectionManager, requestConnectionToConnectionManager, resetOperationTime, setAddPstmt, setAddString, setAutoCommit, setConnectionManager, setConnectionProperties, setConnMgrID, setDatabaseURL, setDataSourceName, setPassword, setPoolName, setSharedConnection, setStatementPoolSize, setUpdateString, setUser, setWaitRetry, verifyConnection
 
Methods inherited from class com.ibm.btt.services.PoolableServiceImpl
getGrantTime, getUID, setGrantTime, setUID
 
Methods inherited from class com.ibm.btt.services.BTTServiceImpl
getInactiveTimeout, getLastAccess, processRequest, setInactiveTimeout, setLastAccess
 
Methods inherited from class com.ibm.btt.base.Service
externalizer, getExternalizer, getName, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, setName, toString, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.btt.services.jdbcjournalservice.JournalService
close, open
 
Methods inherited from interface com.ibm.btt.services.jdbcservicesinfra.DatabaseConnect
getDataSourceName, isWaitRetry, setDataSourceName, setWaitRetry
 

Field Detail

columnsTable

protected Hashtable columnsTable
Contains information about the relationship between a column in the database table and a data field in the context. Has the following structure: key = column_name, value = data_field_name


createSchema

protected boolean createSchema
Keeps whether the journal schema was also created in the database or not.


schemaName

protected java.lang.String schemaName
Keeps the name of the schema where all journal tables are defined.


wrapNumber

protected int wrapNumber
Keeps the number of the generation being used by the current journal.


date

protected java.lang.String date
Keeps the today date


tableName

protected java.lang.String tableName
Keeps the table name that is schemaName.entity_wrapNumber.


lastRecordNumberFromTable

protected int lastRecordNumberFromTable

var_insert

protected static final java.lang.String var_insert
See Also:
Constant Field Values

var_update

protected static final java.lang.String var_update
See Also:
Constant Field Values

var_where

protected static final java.lang.String var_where
See Also:
Constant Field Values

resetSem

protected static java.lang.Object resetSem

poolSem

protected static java.lang.Object poolSem

singleTableReset

protected static boolean singleTableReset
Constructor Detail

JDBCJournalImpl

public JDBCJournalImpl()
This constructor creates a JDBCJournal object.


JDBCJournalImpl

public JDBCJournalImpl(java.lang.String anEntityName,
                       java.lang.String aSchemaName)
                throws DSEInvalidRequestException
This constructor creates a JDBCJournal object. It sets the entityName and the schemaName attributes to the values passed as arguments.

Parameters:
anEntityName - java.lang.String - the Entity name
aSchemaName - java.lang.String - the Schema name
Throws:
DSEInvalidRequestException - if the request is not valid
Method Detail

addRecord

public int addRecord(Hashtable aDataHashtable)
              throws DSEInvalidRequestException,
                     DSEInvalidArgumentException,
                     DSEInternalErrorException,
                     DSESQLException
Inserts the data in aDataHashtable as a new row in the current journal table. The data hashtable has the format: key=data_field_name, value=data_field_value

Specified by:
addRecord in interface JournalService
Specified by:
addRecord in class JournalImpl
Parameters:
aDataHashtable - Hashtable - the Hashtable with the data to be inserted in the database table
Returns:
int - the row number where the data is inserted
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

buildAddString

protected void buildAddString()
                       throws DSESQLException,
                              DSEInternalErrorException,
                              DSEInvalidRequestException,
                              DSEInvalidArgumentException,
                              DSEException
Builds an instance variable that is used when adding a record.

Specified by:
buildAddString in class JDBCServiceImpl
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSESQLException - if an SQLException is caught
DSEObjectNotFoundException - if the JDBCServicesConnectionManager cannot be found
DSEException - if an exception is thrown when calling the pool of connections manager

buildConnectionProperties

protected void buildConnectionProperties()
Builds the hashtable containing all details needed to request the database connection. It is called by the initializeFrom() method.

Overrides:
buildConnectionProperties in class JDBCServiceImpl

buildUpdateString

protected void buildUpdateString()
                          throws DSESQLException,
                                 DSEInternalErrorException,
                                 DSEInvalidRequestException,
                                 DSEInvalidArgumentException,
                                 DSEException
Builds an instance variable that is used when updating all columns of a record.

Specified by:
buildUpdateString in class JDBCServiceImpl
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSESQLException - if an SQLException is caught
DSEObjectNotFoundException - if the JDBCServicesConnectionManager cannot be found
DSEException - if an exception is thrown when calling the pool of connections manager

commit

public void commit()
            throws DSESQLException
Commits all changes to the database. If the autoCommit attribute is set to true, it does nothing.

Specified by:
commit in interface JournalService
Specified by:
commit in class JournalImpl
Throws:
DSESQLException - if commit failed

controlTableName

protected java.lang.String controlTableName()
Returns the current Control Table name. The Control Table is a specific table within the journal schema that the journal service uses internally to store information about the entities and the number of generations of the journalling system. The Control Table name can be modified by changing the CONTROL_TABLE_NAME attribute in the JournalConstants class.

Specified by:
controlTableName in class JournalImpl
Returns:
String

currentGenerationDate

public java.lang.String currentGenerationDate()
                                       throws DSEInternalErrorException,
                                              DSESQLException
Returns the last date that the journal service was used by a specific entity. A date is assigned to the journal instance as soon as it is created. When a journal is opened, this date and the currentJournallingDate (usually today's date) are compared. If the latter is greater, this method selects to generate a new table and this generation is used for that specific entity. Note that the oldest generation is deleted if the maximum number of generations has been exceeded. If both dates are equal, the current table generation is used.

Specified by:
currentGenerationDate in class JournalImpl
Returns:
java.lang.String - the current generation date with format yyyymmdd
Throws:
DSEInternalErrorException - if an internal Program error is detected
DSESQLException - if a SQLException occurs

currentWrapNumber

protected int currentWrapNumber()
                         throws DSEInternalErrorException,
                                DSEInvalidRequestException,
                                DSEInvalidArgumentException,
                                DSESQLException
Returns the current table generation number being used by the journal instance for the schema set in the schemaName attribute.

Returns:
int - the current wrap number
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

currentWrapNumberForSchema

protected int currentWrapNumberForSchema(java.lang.String aSchemaName)
                                  throws DSEInternalErrorException,
                                         DSEInvalidRequestException,
                                         DSEInvalidArgumentException,
                                         DSESQLException
Returns the current table generation number being used by the journal instance for the schema aSchemaName.

Parameters:
aSchemaName - java.lang.String - the journal schema name
Returns:
int - the current wrap number
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

deleteJournalContent

protected void deleteJournalContent(int aGeneration)
                             throws DSEInternalErrorException,
                                    DSESQLException
Deletes the contents of a current journal table. This is an internal method.

Parameters:
aGeneration - int
Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

deleteRecord

protected void deleteRecord(int aRecordNumber)
                     throws DSEInternalErrorException,
                            DSESQLException
Deletes a record in the current journal table. This method is an internal method.

Parameters:
aRecordNumber - int
Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

getColumnsTable

public Hashtable getColumnsTable()
Returns the columnsTable attribute value of the current journal.

Returns:
Hashtable - the Hashtable that holds the column information

getDatabaseConnection

protected java.sql.Connection getDatabaseConnection()
Returns the databaseConnection attribute value.

Overrides:
getDatabaseConnection in class JDBCServiceImpl
Returns:
Connection - the connection to the database

getEntities

public Vector getEntities()
                   throws DSESQLException,
                          DSEInternalErrorException
Retrieves all entities from the Database.

Returns:
com.ibm.dse.base.Vector, the vector containing all journal entities
Throws:
DSESQLException - if an SQLException is caught
DSEInternalErrorException - if an internal program error occurs

getNumberOfGenerations

public int getNumberOfGenerations()
                           throws DSESQLException,
                                  DSEInternalErrorException
Returns the number of journal generations.

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

getSchemaName

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

Specified by:
getSchemaName in class JournalImpl
Returns:
java.lang.String - the journal schema name

getTableName

public java.lang.String getTableName()
Returns the current journal tableName.

Specified by:
getTableName in class JournalImpl
Returns:
java.lang.String

getWrapNumber

protected int getWrapNumber()
Returns the wrapNumber attribute value

Returns:
int - the wrap number

initializeColumnFrom

public java.lang.Object initializeColumnFrom(Tag aTag)
Used by the JDBCJournal service externalizer to create the contents of the columnsTable instance attribute. The columnsTable is a Hashtable with a key that is the column name and a value that is the data field name for the context whose value corresponds to that column in the database journal table.

Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEException
Used by the services externalizer to set the JDBCJournal instance attributes as defined in the XML file.

Specified by:
initializeFrom in interface Externalizable
Overrides:
initializeFrom in class BTTServiceImpl
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException - if an I/O exception occurs.
DSEException

isConnected

public boolean isConnected()
                    throws DSEInvalidRequestException,
                           DSEInternalErrorException,
                           DSESQLException,
                           DSEObjectNotFoundException,
                           DSEException
Returns true if there is a connection to the database or false if there is not.

Specified by:
isConnected in interface DatabaseConnect
Overrides:
isConnected in class JDBCServiceImpl
Returns:
boolean
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught
DSEObjectNotFoundException
DSEException

isCreateSchema

public boolean isCreateSchema()
Returns the createSchema property value. It is true if a database schema has been created for the journal schema.

Specified by:
isCreateSchema in class JournalImpl
Returns:
boolean

isValidEntity

public boolean isValidEntity()
                      throws DSEInternalErrorException,
                             DSESQLException
Returns true if the entity set for the current journal is valid or false if it is not. It accesses the journal control table to check if * there is a row with an ENTITY_NAME column value that matches the journal instance entity name.

Specified by:
isValidEntity in class JournalImpl
Returns:
boolean
Throws:
DSEInternalErrorException - if an internal program error is detected
DSESQLException - if a SQLException is caught

journalTableRowInsertDefinition

protected java.lang.String journalTableRowInsertDefinition()
                                                    throws DSEInvalidArgumentException,
                                                           DSEInvalidRequestException,
                                                           DSEInternalErrorException,
                                                           DSESQLException
Returns the Journal Table Row definition for an SQL INSERT request. It builds a string with the following format: " ( " + " column_name1,"+.....+ "column_namen)" + " VALUES(?,"+ .... + ?)" Example of usage: "INSERT INTO thisTable aFormatedString" where aFormatedString = "( REC_NBR, ACC_NBR, AMOUNT, DATE, DESC) VALUES (?, ?, ?, ?, ?)"

Returns:
java.lang.String
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught
DSEInvalidRequestException - if the request is invalid

newFor

public static JDBCJournalImpl newFor(java.lang.String anEntityName,
                                     java.lang.String aSchemaName)
                              throws DSEInvalidRequestException
Returns a new JDBCJournal instance with the entityName and schemaName attributes set to the provided values.

Parameters:
anEntityName - java.lang.String, the name of the Entity
aSchemaName - java.lang.String, the name of the Schema
Returns:
JDBCJournal - the new JDBCJournal instance
Throws:
DSEInvalidRequestException - if the request is not valid

nextWrapNumber

protected int nextWrapNumber()
                      throws DSEInternalErrorException,
                             DSEInvalidRequestException,
                             DSEInvalidArgumentException,
                             DSESQLException
Returns the next generation number to be used for the default schema.

Returns:
int - the next wrap number
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

nextWrapNumberForSchema

protected int nextWrapNumberForSchema(java.lang.String aSchemaName)
                               throws DSEInternalErrorException,
                                      DSEInvalidRequestException,
                                      DSEInvalidArgumentException,
                                      DSESQLException
Returns the next generation number available for the specified schema.

Parameters:
aSchemaName - java.lang.String - the journal schema name
Returns:
int - the generation number
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

open

public void open(java.lang.String anEntity,
                 int aGeneration)
          throws DSEInvalidRequestException,
                 DSEInternalErrorException,
                 DSESQLException
Opens the journal service with an entity and a generation number

Specified by:
open in interface JournalService
Parameters:
anEntity - java.lang.String
aGeneration - int
Throws:
DSEInvalidRequestException - if journal service state is active
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

open

public void open(java.lang.String aSchemaName,
                 java.lang.String anEntity,
                 int aGeneration)
          throws DSEInvalidRequestException,
                 DSEInternalErrorException,
                 DSESQLException
Opens the journal service with a specific shema, an entity, and a generation number.

Specified by:
open in interface JournalService
Parameters:
aSchemaName - java.lang.String
anEntity - java.lang.String
aGeneration - int
Throws:
DSEInvalidRequestException - if journal service state is active
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

openForEntity

public void openForEntity(java.lang.String anEntity)
                   throws DSEInternalErrorException,
                          DSEInvalidRequestException,
                          DSEInvalidArgumentException,
                          DSESQLException
Opens the current journal table for anEntity. It sets the entity property to anEntity and calls the open() method.

Specified by:
openForEntity in interface JournalService
Parameters:
anEntity - java.lang.String, the name of the entity
Throws:
DSEInvalidRequestException - if the entity name is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if an argument is not valid
DSESQLException - if a SQLException occurs

openForEntity

public void openForEntity(java.lang.String anEntity,
                          java.lang.String aSchemaName)
                   throws DSEInternalErrorException,
                          DSEInvalidRequestException,
                          DSEInvalidArgumentException,
                          DSESQLException
Decides which is going to be the current journal table for anEntity. It sets the entity property to anEntity, the schemaName attribute to aSchemaName, and calls the open() method.

Specified by:
openForEntity in interface JournalService
Parameters:
anEntity - java.lang.String, the name of the entity
aSchemaName - java.lang.String, the name of the schema
Throws:
DSEInvalidRequestException - if the entity name is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if an argument is not valid
DSESQLException - if a SQLException occurs

openForSchema

public void openForSchema(java.lang.String aSchemaName)
                   throws DSEInternalErrorException,
                          DSEInvalidRequestException,
                          DSEInvalidArgumentException,
                          DSESQLException
Decides which is going to be the current journal table. It sets the schemaName property to aSchemaName and calls the open() method.

Specified by:
openForSchema in interface JournalService
Parameters:
aSchemaName - java.lang.String, the name of the schema
Throws:
DSEInvalidRequestException - if the entity name is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if an argument is not valid
DSESQLException - if a SQLException occurs

openOnCurrentTable

public void openOnCurrentTable()
                        throws DSEInvalidRequestException,
                               DSEInternalErrorException,
                               DSEInvalidArgumentException,
                               DSESQLException
Selects the already selected table generation for the current schema as the current journal table. It sets the journal attributes to a value that is adequate to start working with this table.

Specified by:
openOnCurrentTable in class JournalImpl
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

openOnCurrentTableForSchema

public void openOnCurrentTableForSchema(java.lang.String aSchemaName)
                                 throws DSEInvalidRequestException,
                                        DSEInternalErrorException,
                                        DSEInvalidArgumentException,
                                        DSESQLException
Selects the already selected table generation for the specified schema as the current journal table. It sets the journal attributes to a value that is adequate to start working with this table.

Parameters:
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

openOnNextTable

public void openOnNextTable()
                     throws DSEInternalErrorException,
                            DSEInvalidRequestException,
                            DSEInvalidArgumentException,
                            DSESQLException
Selects the next available table generation for the current schema as the current journal table. It sets the journal attributes to a value that is adequate to start working with this table.

Specified by:
openOnNextTable in class JournalImpl
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

openOnNextTableForSchema

public void openOnNextTableForSchema(java.lang.String aSchemaName)
                              throws DSEInternalErrorException,
                                     DSEInvalidRequestException,
                                     DSEInvalidArgumentException,
                                     DSESQLException
Selects the next available table generation for the specified schema as the current journal table. It sets the journal attributes to a value that is adequate to start working with this table.

Parameters:
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

resetSingleTableLastRecordNumber

public void resetSingleTableLastRecordNumber()
                                      throws DSESQLException,
                                             DSEInternalErrorException
Resets the Journal last record number when different instances are accessing the same tables

Specified by:
resetSingleTableLastRecordNumber in class JournalImpl
Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

queryLastRecordNumber

public int queryLastRecordNumber()
                          throws DSESQLException,
                                 DSEInternalErrorException
Returns the last record number in the current journal table. The database is accessed to get this information.

Specified by:
queryLastRecordNumber in interface JournalService
Specified by:
queryLastRecordNumber in class JournalImpl
Returns:
int
Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

recordToRow

protected Vector recordToRow(Hashtable aDataHashtable)
                      throws DSEInvalidRequestException,
                             DSEInternalErrorException,
                             DSEInvalidArgumentException,
                             DSESQLException
Returns a list of ordered data field values. Each of these values are inserted in the column with column index matching the position in the list. It uses as input the data Hashtable with key the data field name and value the data field formatted value, and the columns Hashtable set when the service is instantiated (columnsTable attribute). The columns information will be requested by the JDBCJournalSchemaGenerator class calling its getMetaData() method.

Parameters:
aDataHashtable - Hashtable, the data to be used to build the database record
Returns:
com.ibm.dse.base.Vector - a vector of data field values
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

retrieveLastRecord

public Hashtable retrieveLastRecord()
                             throws DSEInternalErrorException,
                                    DSEInvalidArgumentException,
                                    DSESQLException
Retrieves the last record of the current journal table.

Specified by:
retrieveLastRecord in interface JournalService
Specified by:
retrieveLastRecord in class JournalImpl
Returns:
Hashtable - a Hashtable built from the retrieved record column values
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

retrieveLastRecords

public Vector retrieveLastRecords(int aNumber)
                           throws DSEInternalErrorException,
                                  DSEInvalidArgumentException,
                                  DSEInvalidRequestException,
                                  DSESQLException
Returns a vector with aNumber or any number between 0 and aNumber of record Hashtables.

Specified by:
retrieveLastRecords in interface JournalService
Specified by:
retrieveLastRecords in class JournalImpl
Parameters:
aNumber - int, the number of records to retrieve
Returns:
com.ibm.dse.base.Vector
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

retrieveRecord

public Hashtable retrieveRecord(int aRecordNumber)
                         throws DSEInternalErrorException,
                                DSEInvalidArgumentException,
                                DSESQLException
Retrieves the record with the record identification in the database equal to aRecordNumber.

Specified by:
retrieveRecord in interface JournalService
Specified by:
retrieveRecord in class JournalImpl
Parameters:
aRecordNumber - int - the record number
Returns:
Hashtable - a Hashtable built from the retrieved record column values
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

retrieveRecords

public Vector retrieveRecords(java.lang.String aSearchCondition)
                       throws DSEInternalErrorException,
                              DSEInvalidRequestException,
                              DSEInvalidArgumentException,
                              DSESQLException
Retrieves all the records within the current journal that match aSearchCondition.

Specified by:
retrieveRecords in interface JournalService
Specified by:
retrieveRecords in class JournalImpl
Parameters:
aSearchCondition - java.lang.String - the search condition in SQL format
Returns:
com.ibm.dse.base.Vector
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

retrieveRecords

public Vector retrieveRecords(java.lang.String aSearchCondition,
                              Vector aColumnsVector)
                       throws DSEInternalErrorException,
                              DSEInvalidRequestException,
                              DSEInvalidArgumentException,
                              DSESQLException
Retrieves the columns in aColumnsVector of all the records within the current journal that match aSearchCondition.

Specified by:
retrieveRecords in interface JournalService
Parameters:
aSearchCondition - java.lang.String - the search condition in SQL format
aColumnsVector - com.ibm.dse.base.Vector - the vector that contains the columns to be retrieved
Returns:
com.ibm.dse.base.Vector - the vector of hash tables with the retrieved records
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

rollback

public void rollback()
              throws DSESQLException
Rolls back all database changes.

Specified by:
rollback in interface JournalService
Specified by:
rollback in class JournalImpl
Throws:
DSESQLException - Thrown when the rollback fails

setColumnsTable

protected void setColumnsTable(Hashtable aColumnsHashtable)
Sets the columnsTable property to aColumnsHashtable value. The columns hashtable has the following format: key=column_name, value=data_field_name

Parameters:
aColumnsHashtable - Hashtable

setCreateSchema

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

Specified by:
setCreateSchema in class JournalImpl
Parameters:
newCreateSchema - boolean

setDatabaseConnection

protected void setDatabaseConnection(java.sql.Connection aDatabaseConnection)
Sets the database connection property to aDatabaseConnection.

Overrides:
setDatabaseConnection in class JDBCServiceImpl
Parameters:
aDatabaseConnection - Connection

setEntity

public void setEntity(java.lang.String anEntityName)
Sets the entity property value to anEntityName.

Specified by:
setEntity in interface JournalService
Specified by:
setEntity in class JournalImpl
Parameters:
anEntityName - java.lang.String

setSchemaName

public void setSchemaName(java.lang.String aSchemaName)
Sets the schemaName property to aSchemaName

Specified by:
setSchemaName in class JournalImpl
Parameters:
aSchemaName - java.lang.String - the journal schema name

setTableName

protected void setTableName(java.lang.String aTableName)
Sets the tableName.

Specified by:
setTableName in class JournalImpl
Parameters:
aTableName - java.lang.String

tableName

protected java.lang.String tableName(java.lang.String aSchemaName,
                                     java.lang.String anEntityName,
                                     int aGeneration)
Returns the journal table name for a specific schema name, entity name and generation.

Parameters:
aSchemaName - java.lang.String, the schema name
anEntityName - java.lang.String - the entity name
aGeneration - int - the generation number
Returns:
java.lang.String

toStrings

public Vector toStrings()
Used by the Db2Journal service externalizer.

Specified by:
toStrings in interface Externalizable
Overrides:
toStrings in class Service
Returns:
com.ibm.dse.base.Vector

updateLastRecord

public int updateLastRecord(Hashtable aDataHashtable)
                     throws DSEInvalidRequestException,
                            DSEInternalErrorException,
                            DSEInvalidArgumentException,
                            DSESQLException
Updates the last record of the current journal table with the data in aDataHashtable. It calls the method updateRecords(String,Hashtable).

Specified by:
updateLastRecord in interface JournalService
Specified by:
updateLastRecord in class JournalImpl
Parameters:
aDataHashtable - Hashtable - the Hashtable that contains the data
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if an argument is not valid
DSEInvalidRequestException - if the input parameters are not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

updateLastRecord

public int updateLastRecord(Hashtable aDataHashtable,
                            Vector aColumnsVector)
                     throws DSEInvalidRequestException,
                            DSEInternalErrorException,
                            DSEInvalidArgumentException,
                            DSESQLException
Updates the columns in aColumnsVector for the last record of the current journal table with the data in aDataHashtable. It calls the method updateRecords(String,Hashtable,Vector).

Specified by:
updateLastRecord in interface JournalService
Parameters:
aDataHashtable - Hashtable - the Hashtable that contains the data
aColumnsVector - com.ibm.dse.base.Vector - the columns to be changed
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if an argument is not valid
DSEInvalidRequestException - if the input parameters are not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

updateRecord

public int updateRecord(int aRecordNumber,
                        Hashtable aDataHashtable)
                 throws DSEInvalidRequestException,
                        DSEInternalErrorException,
                        DSEInvalidArgumentException,
                        DSESQLException
Updates the record identified by aRecordNumber within the journal table with the data provided in aDataHashtable by calling the updateRecords(String, Hashtable) method.

Specified by:
updateRecord in interface JournalService
Specified by:
updateRecord in class JournalImpl
Parameters:
aRecordNumber - int - the number of the record to be updated
aDataHashtable - Hashtable - the Hashtable containing the new data
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if an argument is not valid
DSEInvalidRequestException - if the input parameters are not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

updateRecord

public int updateRecord(int aRecordNumber,
                        Hashtable aDataHashtable,
                        Vector aColumnsVector)
                 throws DSEInvalidArgumentException,
                        DSEInternalErrorException,
                        DSEInvalidRequestException,
                        DSESQLException
Updates the columns specified in aColumnsVector, for the record identified by aRecordNumber within the journal table, with the data provided in aDataHashtable. The aDataHashtable should only contain the values for the columns to be updated.

Specified by:
updateRecord in interface JournalService
Parameters:
aRecordNumber - int - the number of the record to be updated
aDataHashtable - com.ibm.dse.base.Hashtable - the Hashtable that contains the new data
aColumnsVector - com.ibm.dse.base.Vector - the columns to be changed
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid.
DSEInternalErrorException - if an internal program error occurs.
DSEInvalidRequestException - if the request is not valid.
com.ibm.dse.services.jdbc.DSESQLException - if an SQLException is caught.
DSEInvalidArgumentException
DSEInternalErrorException
DSEInvalidRequestException
DSESQLException

updateRecords

public int updateRecords(java.lang.String aSearchCondition,
                         Hashtable aDataHashtable)
                  throws DSEInvalidRequestException,
                         DSEInternalErrorException,
                         DSEInvalidArgumentException,
                         DSESQLException
Updates all the current journal table records that match the search condition with the aDataHashtable data.

Specified by:
updateRecords in interface JournalService
Specified by:
updateRecords in class JournalImpl
Parameters:
aSearchCondition - java.lang.String - the search condition
aDataHashtable - Hashtable - the Hashtable that contains the new data
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if an argument is not valid
DSEInvalidRequestException - if the input parameters are not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught

updateRecords

public int updateRecords(java.lang.String aSearchCondition,
                         Hashtable aDataHashtable,
                         Vector aColumnsVector)
                  throws DSEInvalidArgumentException,
                         DSEInternalErrorException,
                         DSEInvalidRequestException,
                         DSESQLException
Updates the columns specified in aColumnsVector with the data provided in aDataHashtable for the records matching the search condition within the journal table. The aDataHashtable should only contain the values for the columns to be updated.

Specified by:
updateRecords in interface JournalService
Parameters:
aSearchCondition - java.lang.String - the search condition
aDataHashtable - com.ibm.dse.base.Hashtable - the Hashtable that contains the new data
aColumnsVector - com.ibm.dse.base.Vector - the columns to be changed
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid.
DSEInternalErrorException - if an internal program error occurs.
DSEInvalidRequestException - if the request is not valid.
com.ibm.dse.services.jdbc.DSESQLException - if an SQLException is caught.
DSEInvalidArgumentException
DSEInternalErrorException
DSEInvalidRequestException
DSESQLException

isSingleTableReset

public static boolean isSingleTableReset()
Returns the singleTableReset.

Returns:
boolean

setSingleTableReset

public static void setSingleTableReset(boolean singleTableReset)
Sets the singleTableReset.

Parameters:
singleTableReset - The singleTableReset to set

disconnect

public void disconnect()
                throws DSESQLException,
                       DSEException
Description copied from interface: DatabaseConnect
Closes the Database connection.

Specified by:
disconnect in interface DatabaseConnect
Overrides:
disconnect in class JDBCServiceImpl
Throws:
DSESQLException - if a SQLException occurs
DSEException - if an exception is thrown when calling the pool of connections manager
See Also:
DatabaseConnect.disconnect()

handleCommand

public java.lang.Object handleCommand(java.lang.String opName,
                                      java.util.Hashtable requestParam)
                               throws java.lang.Exception
Description copied from class: JDBCServiceImpl
handleCommand just pass parameter to service, and let the service object execute operation

Overrides:
handleCommand in class JDBCServiceImpl
Throws:
java.lang.Exception
See Also:
BTTServiceImpl.handleCommand(String, Hashtable)

connect

public void connect(java.lang.String anUser,
                    java.lang.String aPassword)
             throws DSESQLException,
                    DSEInvalidRequestException,
                    DSEInternalErrorException,
                    DSEObjectNotFoundException,
                    DSEException
Description copied from interface: DatabaseConnect
Connects to the Database set in the DataSource definition, with user identification aUser and password aPassword. Can only be used if the connection is requested to a pool of connections implemented as a DataSource with the database URL specified as part of the DataSource definition

Specified by:
connect in interface DatabaseConnect
Overrides:
connect in class JDBCServiceImpl
Parameters:
anUser - java.lang.String - the user identification
aPassword - java.lang.String - the user password
Throws:
DSEObjectNotFoundException - if the JDBCServicesConnectionManager cannot be found
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSEException - if an exception is thrown when calling the pool of connections manager
DSESQLException - if an SQLException is caught
See Also:
DatabaseConnect.connect(String, String)

getLastRecordNumberFromTable

public int getLastRecordNumberFromTable()
                                 throws DSEInvalidRequestException
Returns the lastRecordNumber from control table. In this method, all accesses are exclusive.

Specified by:
getLastRecordNumberFromTable in interface JournalService
Specified by:
getLastRecordNumberFromTable in class JournalImpl
Returns:
int
Throws:
DSEInvalidRequestException

setLastRecordNumberFromTable

public void setLastRecordNumberFromTable(int aLastRecordNumberFromTable)
Sets the lastRecordNumberFromTable into control table.

Specified by:
setLastRecordNumberFromTable in class JournalImpl
Parameters:
aLastRecordNumberFromTable - The lastRecordNumberFromTable to set

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005