WebSphere Extended Deployment Compute Grid, Version 6.1
             Operating Systems: AIX, HP-UX, Linux, Solaris, Windows, z/OS


JDBCReaderPattern

This pattern is used to retrieve data from a database using a Java Database Connectivity (JDBC) connection.

Supporting classes

  1. CursorHoldableJDBCReader
    This class is referenced when the usage pattern of your JDBC input stream retrieves a set of results at the beginning of the step, and then iterates over them throughout the step-processing logic. The CursorHoldableJDBCReader uses a stateful session bean with a cursor-holdable, non-XA data source. As a result, ResultSets do not need to be repopulated after every checkpoint, which improves performance. To use CursorHoldableJDBCReader, package the CursorHoldableSessionBean in your application. To create the package, add the nonxadsjndiname=jndi_name_of_a_non-XA_data_source_to_database property to the properties file that is used by the BatchPackager. For example, nonxadsjndiname=jdbc/nonxads.If you want to add multiple non-XA datasources enter the following: nonxadsjndiname=<jndi name1>;<jndi name2>...
    Restriction: Currently, the resource reference name of the JDBC data source is the same as the Java Naming and Directory Interface (JNDI) name.
  2. JDBCReader

    This class is referenced when the usage pattern of your JDBC input stream retrieves a single result from a query, which is used and discarded after every iteration of the step.

  3. LocalJDBCReader

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

Required properties

Table 1. Required properties
Property Value LocalJDBCReader CursorHoldableJDBCReader JDBCReader
PATTERN_IMPL_CLASS Class implementing JDBCReaderPattern interface

Applicable

Applicable

Applicable

ds_jndi_name Datasource JNDI name.

Applicable

Not applicable

Applicable

jdbc_url The JDBC URL. For example, jdbc:derby:C:\\mysample\\CREDITREPORT.

Applicable

Not applicable

Not applicable

jdbc_driver The JDBC driver. For example, org.apache.derby.jdbc.EmbeddedDriver

Applicable

Not applicable

Not applicable

userid The user ID for the database. For example, Myid

Applicable

Not applicable

Not applicable

pswd User password. For example, mypwd. LocalJDBCReader only.

Applicable

Not applicable

Not applicable

Optional properties

Table 2. Optional properties
Property name Value Description LocalJDBCReader CursorHoldableJDCReader JDBCReader

debug

true or false (default is false)

Enables detailed tracing on this batch datastream.

Applicable

Applicable

Applicable

EnablePerformanceMeasurement

true or false (default is false)

Calculates the total time spent in the batch data-streams and the processRecord method, if you are using the GenericXDBatchStep.

Applicable

Applicable

Applicable

EnableDetailedPerformanceMeasurement

true or false (default is false)

Provides a more detailed breakdown of time spent in each method of the batch data-streams.

Applicable

Applicable

Applicable

Interface definition

public interface JDBCReaderPattern {

	/**
	 * 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 SQL query that will be used during setup of the stream to retrieve all relevant
	 * data that would be processed part of the job steps
	 * @return object to be used during process step.
	 */
	public String getInitialLookupQuery();
	
	/**
	 * This method gets called during Job Restart. The restart token should be used to create an SQL query 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 String getRestartQuery(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();
		
}

xJCL example

<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/>
<prop name="ds_jndi_name" value="jdbc/fvtdb"/>
<prop name="debug" value="true"/>
<prop name="DEFAULT_APPLICATION_NAME" value="XDCGIVT"/> <!-- versions prior to 6103 only -->
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.CursorHoldableJDBCReader</impl-class>
</bds>
</batch-data-streams>

xJCL example

<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoReader"/>
<prop name="jdbc_url" value="jdbc:derby:C:\\mysample\\CREDITREPORT"/>
<prop name="jdbc_driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<prop name="user_id" value="myuserid"/>
<prop name="pswd" value="mypswd"/>
<prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCReader</impl-class>
</bds>
</batch-data-streams>



Related concepts
[Version 6.1.0.3 and later] Batch data stream framework and patterns
Related tasks
[For z/OS operating system] [Version 6.1.0.3 and later] Using the batch data stream (BDS) framework
Related information
[Version 6.1.0.3 and later] JDBCWriterPattern
[For z/OS operating system] [Version 6.1.0.3 and later] ByteReaderPattern
[Version 6.1.0.3 and later] ByteWriterPattern
[Version 6.1.0.3 and later] FileReaderPattern
[Version 6.1.0.3 and later] FileWriterPattern
[Version 6.1.0.3 and later] RecordOrientedDatasetReaderPattern
[For z/OS operating system] [Version 6.1.0.3 and later] RecordOrientedDataSetWriterPattern
[Version 6.1.0.5 and later] JPAReaderPattern
[Version 6.1.0.5 and later] JPAWriterPattern
Reference topic    

Terms of Use | Feedback

Last updated: Oct 30, 2009 6:22:31 PM EDT
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/index.jsp?topic=/com.ibm.websphere.gridmgr.doc/info/scheduler/rbtchpttrnjd.html