+

Search Tips   |   Advanced Search

JDBCCallableStatementReaderPattern

This pattern is used to implement the business logic of processing data from a JDBC connection using a stored procedure. The administrative tasks of opening and closing the connection are done by the batch framework.


Supporting classes

  1. JDBCCallableStatementReader

    This class is referenced when the usage pattern of our 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.

  2. LocalJDBCCallableStatementReader

    This class is referenced when data is read from a local database.


Required properties

The following properties are required for the pattern.

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


Optional properties

The following properties are optional for the pattern.

Property name Value Description JDBCCallableStatementReader LocalJDBCCallableStatementReader
CursorHoldabilityEnabled true or false (default is false) Enable Cursor Holdability for this BDS Reader Applicable Applicable
debug true or false. The default is false. Enable detailed tracing on this batch data stream. Applicable Applicable
EnablePerformanceMeasurement true or false. The default is false. Calculates the total time spent in the batch data streams and the processRecord method, if we are using the GenericXDBatchStep. Applicable Applicable
EnableDetailedPerformanceMeasurement true or false. The default is false. Provides a more detailed breakdown of time spent in each method of the batch data streams. Applicable Applicable


Interface definition

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();
		 		 
}


JDBCCallableStatementReader xJCL example

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


Related:

  • Batch data stream framework and patterns
  • Use the batch data stream framework
  • JDBCWriterPattern
  • ByteReaderPattern
  • ByteWriterPattern
  • FileReaderPattern
  • FileWriterPattern
  • (ZOS) RecordOrientedDatasetReaderPattern
  • (ZOS) RecordOrientedDataSetWriterPattern
  • JPAReaderPattern
  • JPAWriterPattern