This pattern is used to implement the business logic of processing data from a Java Database Connectivity (JDBC) connection using a stored procedure. The administrative tasks of opening and closing the connection are done by the batch framework.
This class is referenced when the usage pattern of your JDBC input stream retrieves a single result from a query. The query and results are discarded after every iteration of the step. This class differs from JDBCReader in that it uses a callable statement instead of a prepared statement.
This class is referenced when data is read from a local database.
Property | Value | JDBCCallableStatementReader | LocalJDBCCallableStatementReader |
---|---|---|---|
PATTERN_IMPL_CLASS | The class implementing JDBCCallableStatementReaderPattern interface. | Applicable | Applicable |
ds_jndi_name | The data source JNDI name. | Applicable | Applicable |
jdbc_url | The JDBC URL. For example, jdbc:derby:C:\\mysample\\CREDITREPORT. | Not applicable | Applicable |
jdbc_driver | The JDBC driver. For example, org.apache.derby.jdbc.EmbeddedDriver | Not applicable | Applicable |
userid | The user ID for the database. | Not applicable | Applicable |
pswd | The user password. | Not applicable | Applicable |
Property name | Value | Description | JDBCCallableStatementReader | LocalJDBCCallableStatementReader |
---|---|---|---|---|
CursorHoldabilityEnabled | true or false (default is false) | Enables Cursor Holdability for this BDS Reader | Applicable | Applicable |
debug | true or false. The default value is false. | Enables detailed tracing on this batch data stream. | Applicable | Applicable |
EnablePerformanceMeasurement | true or false. The default value is false. | Calculates the total time spent in the batch data streams and the processRecord method, if you are using the GenericXDBatchStep. | Applicable | Applicable |
EnableDetailedPerformanceMeasurement | true or false. The default value is false. | Provides a more detailed breakdown of time spent in each method of the batch data streams. | Applicable | Applicable |
public interface JDBCCallableStatementReaderPattern {
/**
* This method is invoked during the job setup phase.
*
* @param props properties provided in the xJCL
*/
public void initialize(Properties props);
/**
* This method should retrieve values for the various columns for the current row from
* the given resultset object. Typically this data would be used to populate an
* intermediate object which would be returned
* @param resultSet
* @return
*/
public Object fetchRecord(ResultSet resultSet);
/**
* This method should return a ResultSet used by the stream to retrieve all relevant
* data that would be processed part of the job steps.
*/
public ResultSet getResultSet(CallableStatement cstmt) throws SQLException ;
/**
* This method should return a Callable statement that will be used during setup of the
* stream to retrieve all relevant data that would be processed as part of the job steps.
* @return object to be used during process step.
*/
public CallableStatement getInitialCallableStatement(Connection con);
/**
* This method gets called during Job Restart. The restart token should be used to create
* a Callable Statement that will retrieve previously unprocessed records.
* Typically the restart token would be the primary key in the table and the query would
* get all rows with primary key value > restarttoken
* @param restartToken
* @return The restart query
*/
public CallableStatement getRestartCallableStatement(Connection con,String restartToken);
/**
* This method gets called just before a checkpoint is taken.
* @return The method should return a string value identifying the last record read by the stream.
*/
public String getRestartTokens();
}
<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="IMPLCLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/>
<prop name="ds_jndi_name" value="jdbc/echojndi"/>
<prop name="debug" value="false"/>
<prop name="EnablePerformanceMeasurement" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.JDBCCallableStatementReader</impl-class>
</bds>
</batch-data-streams>