Use this pattern is used to read data from a database using IBM® Optim™ pureQuery Runtime. The batch data stream (BDS) framework completes the administrative tasks of opening and closing connections.
The PureQueryReader class implements the basic operations of opening and closing database connections and obtaining the IBM Optim pureQuery Runtime data.
The following properties are required for the pattern.
Property name | Value |
---|---|
PATTERN_IMPL_CLASS | Class implementing PureQueryReaderPattern interface |
PQ_DATA_BEAN_INTERFACE | PureQuery data bean interface |
ds_jndi_name | Java Naming and Directory Interface (JNDI) name of the data source to access the database |
The following properties are optional for the pattern.
Property name | Value | Description |
---|---|---|
debug | true or false (The default is false.) | Enables detailed tracing on this batch data stream |
DB_SCHEMA | null | Database schema name |
EnablePerformanceMeasurement | true or false (The default is false.) | Calculates the total time spent in the batch data-streams and the processRecord method, if you are using the GenericXDBatchStep |
The PureQueryReaderPattern Interface definition shows the methods that you must implement to support the PureQueryReaderPattern interface.
public interface PureQueryReaderPattern
{
/**
* This method is called by the batch container during step setup. The properties passed
* in are the ones that you provide in the xJCL BDS level properties.
* @param properties
*/
public void initialize(Properties properties);
/**
* Invoked by the container during each iteration of the batch loop. This code obtains
* the next record using the given iterator object.
* @param iterator
* @return
*/
public Object fetchRecord(Iterator iterator);
/**
* Returns the iterator based on the passed data object that is used to iterate
* over the records
* @param data
* @return
*/
public Iterator getInitialIterator(Data data);
/**
* Returns the iterator based on the passed data object repositioned based on the restart
* token of restartToken.
* @param data
* @param s
* @return
*/
public Iterator getRestartIterator(Data data, String restartToken);
/**
* Invoked before a checkpoint is taken to save the restart token that is used in case
* of a restart
* @return
*/
public String getRestartTokens();
}
The example shows xJCL that you can use to define a batch datastream which implements the PureQueryReaderPattern interface in your application.
<batch-data-streams>
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="IMPLCLASS" value="com.ibm.MyWriterPattern"/>
<prop name="ds_jndi_name" value="jdbc/crreport"/>
<prop name="debug" value="true"/>
<prop name="DB_SCHEMA" value="PQDS"/>
<prop name="PQ_DATA_BEAN_INTERFACE" value="com.ibm.MyEmployeeData"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.PureQueryReader</impl-class>
</bds></batch-data-streams>