JDBCWriterPattern

This pattern is used to write data to a database using a JDBC connection.

Supporting classes

  1. JDBCWriter
  2. LocalJDBCWriter

Required properties

The following properties are required for the pattern.
Table 1. Required properties. The table includes the name and value of each required property for the pattern.
Property name Value LocalJDBCWriter JDBCWriter
PATTERN_IMPL_CLASS Class implementing JDBCWriterPattern interface

Applicable

Applicable

ds_jndi_name Datasource JNDI name.

Applicable

Not applicable

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

Applicable

Not applicable

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

Applicable

Not applicable

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

Applicable

Not applicable

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

Applicable

Not applicable

Optional properties

The following properties are optional for the pattern.
Table 2. Optional properties. The table includes the name, value, and description of each optional property for the pattern.
Property name Value Description LocalJDBCReader JDBCWriter

debug

true or false (default is false)

Enables detailed tracing on this batch datastream.

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

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

batch_interval

Default value is 20. Make the value less than the checkpoint interval for record-based checkpointing.

Denotes the number of SQL updates to batch before committing.

Applicable

Applicable

Interface definition

public interface JDBCWriterPattern {

	public void initialize(Properties props);
	
	/**
	 * This is typically an Update query used to write data into the DB
	 * @return
	 */
	public String getSQLQuery();
	
	/**
	 * The parent class BDSJDBCWriter creates a new preparedstatement and
	 * passes it to this method. This method populates the preparedstatement
	 * with appropriate values and returns it to the parent class for execution
	 * @param pstmt
	 * @param record
	 * @return
	 */
	public PreparedStatement writeRecord(PreparedStatement pstmt, Object record);
}

JDBCWriter xJCL example

<batch-data-streams>
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoWriter"/>
<prop name="ds_jndi_name" value="jdbc/fvtdb"/>
<prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.JDBCWriter</impl-class>
</bds>
</batch-data-streams> 

LocalJDCBWriter xJCL example

<batch-data-streams>
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.tests.bds.EchoWriter"/>
<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.LocalJDBCWriter</impl-class>
</bds>
</batch-data-streams> 



Related concepts
Batch data stream framework and patterns
Related tasks
Using the batch data stream (BDS) framework
Related information
JDBCReaderPattern
ByteReaderPattern
ByteWriterPattern
FileReaderPattern
FileWriterPattern
JPAReaderPattern
JPAWriterPattern


Terms of Use | Feedback

Last updatedLast updated: Sep 19, 2011 4:16:02 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-base-dist&topic=rgrid_btchpttrn2
File name: rgrid_btchpttrn2.html