org.osesb.connectors.jdbc
Class UpdateStatementTableSetAdapter

java.lang.Object
  extended by org.osesb.connectors.jdbc.TableSetAdapter
      extended by org.osesb.connectors.jdbc.UpdateStatementTableSetAdapter

public class UpdateStatementTableSetAdapter
extends TableSetAdapter

This Class extends TableSetAdapter with processTableSet() method that executes the configured SQL update statement and returns the result as an Integer for the number of rows that were updated.

If autoCommit is not set on the connection, a commit() is issued after the update succeeds.

By default processTableSet() looks for a SQL statement named 'updateStatement' in the SQLStatementListConfiguration portion of the TableSetConfiguration file. To specify a SQLStatement with a different name, configure an adapter property named 'updateStatementName'.

If the SQL update statement is parameterized, then processTableSet() looks for the values of the sql parameters in a ProcessingContext variable named sqlStatementName.sqlParameters, where 'sqlStatementName' is the name of the configured SQLStatement. The ProcessingContext variable must be an Object[] with the values for the SQLParameters.

The length of the Object[] MUST equal the number of <param> elements configured for the SQLStatement, however, if the value of the parameter is configured as a scripted variable or a constant and if the corresponding entry in the Object[] is null, then the value of the parameter is not updated, but defers to the configured value.

Note: TableSet(s) and TableSetConfiguration(s) are not generally used stand-alone, but are included as part of another configuration that accomplishes an integration function. For example, For example, TableSet(s) are used as operative components in the org.osesb.scheduledjobs.databasepoller package. A database poller scans integration tables for changes.

Since:
Version .9

Field Summary
 
Fields inherited from class org.osesb.connectors.jdbc.TableSetAdapter
log, parentTableSet, tableSetAdapterConfiguration, thisClassName
 
Constructor Summary
UpdateStatementTableSetAdapter(TableSet parentTableSet, TableSetAdapterConfiguration tableSetAdapterConfiguration)
          Creates a new instance of UpdateStatementTableSetAdapter.
 
Method Summary
 java.lang.Object[] doCustomProcessing(java.lang.Object[] parameters)
          Custom processing method.
static void main(java.lang.String[] args)
          main() For testing and sandboxing.
 java.lang.Object[] processStatement(java.lang.String statementName)
          Executes the named SQLStatement configured by the TableSetConfiguration.
 java.lang.Object[] processTableSet()
          Executes the configured SQL update statement and returns the result as an Object[] where the first element of the array is as an Integer for the number of rows that were updated.
 
Methods inherited from class org.osesb.connectors.jdbc.TableSetAdapter
getParentTableSet, logMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateStatementTableSetAdapter

public UpdateStatementTableSetAdapter(TableSet parentTableSet,
                                      TableSetAdapterConfiguration tableSetAdapterConfiguration)
                               throws java.lang.Exception
Creates a new instance of UpdateStatementTableSetAdapter.

Parameters:
parentTableSet - The TableSet that owns this TableSetAdapter.
Throws:
java.lang.Exception - if constructed with a null TableSet.
Method Detail

processTableSet

public java.lang.Object[] processTableSet()
                                   throws java.lang.Exception
Executes the configured SQL update statement and returns the result as an Object[] where the first element of the array is as an Integer for the number of rows that were updated.

By default processTableSet() looks for a SQL statement named 'updateStatement' in the SQLStatementListConfiguration portion of the TableSetConfiguration file. To specify a SQLStatement with a different name, configure an adapter property named 'updateStatementName'.

If the SQL update statement is parameterized, then processTableSet() looks for the values of the sql parameters in a ProcessingContext variable named sqlStatementName.sqlParameters, where 'sqlStatementName' is the name of the configured SQLStatement. The ProcessingContext variable must be an Object[] with the values for the SQLParameters.

The length of the Object[] MUST equal the number of <param> elements configured for the SQLStatement, however, if the value of the parameter is configured as a scripted variable or a constant and if the corresponding entry in the Object[] is null, then the value of the parameter is not updated, but defers to the configured value.

Specified by:
processTableSet in class TableSetAdapter
Returns:
the result of SQL processing of as an Object[] where the first element of the array is an Integer for the number of rows that were updated.
Throws:
java.lang.Exception - if there is a problem with processing the TableSet SQL.

processStatement

public java.lang.Object[] processStatement(java.lang.String statementName)
                                    throws java.lang.Exception
Executes the named SQLStatement configured by the TableSetConfiguration. The SQLStatement is assumed to be an update statement.

Returns the result of SQL processing of as an Object[] where the first element of the array where the first element of the array is as an Integer for the number of rows that were updated.

If the SQL update statement is parameterized, then processStatement() looks for the values of the sql parameters in a ProcessingContext variable named sqlStatementName.sqlParameters, where 'sqlStatementName' is the name of the configured SQLStatement. The ProcessingContext variable must be an Object[] that contains values for the SQLParameters.

The length of the Object[] MUST equal the number of <param> elements configured for the SQLStatement, however, if the value of the parameter is configured as a scripted variable or a constant and if the corresponding entry in the Object[] is null, then the value of the parameter is not updated, but defers to the configured value.

Specified by:
processStatement in class TableSetAdapter
Parameters:
statementName - The name of the SQLStatement to process.
Returns:
the result of SQL processing of as an Object[] where the first element of the array is an Integer for the number of rows that were updated.
Throws:
java.lang.Exception - if there is a problem with processing the TableSet SQL.

doCustomProcessing

public java.lang.Object[] doCustomProcessing(java.lang.Object[] parameters)
                                      throws java.lang.Exception
Custom processing method.

Specified by:
doCustomProcessing in class TableSetAdapter
Parameters:
parameters - Custom processing parameters.
Returns:
the result of custom processing as an Object[].
Throws:
java.lang.Exception - if an error is encountered during custom processing.

main

public static void main(java.lang.String[] args)
main() For testing and sandboxing.

Parameters:
args - commandline arguments