Enabling SQL statement batching

SQL statement batching can improve the performance of your application server. Java Persistence API (JPA) for WebSphere Application Server uses the Java Database Connectivity (JDBC) addBatch and executeBatch APIs to batch statements.

About this task

By default, statement batching is disabled, except with DB2 and Oracle databases. To enable SQL statement batching and to set the batch limit for JPA applications, you need to configure the persistence.xml file. The following steps review how to enable and disable statement batching, as well as set the batch limit:

Procedure

  1. Define the UpdateManager property in the persistence.xml file. For example:
    <property name="openjpa.jdbc.UpdateManager" value="com.ibm.ws.persistence.jdbc.kernel.OperationOrderUpdateManager(batchLimit=100)"/>
    Note: The example shows that the SQL statement batch limit is set to 100.
    Remember: If you are using a DB2 or an Oracle database, SQL statement batching is enabled and set to batchLimit=100 by default. You are not required to specify this property in the persistence.xml file.
  2. If you need to disable SQL statement batching, set the batchLimit value to 0 (zero), or remove the property. If, however, you are using a DB2 or an Oracle database, you need to specify the DBDictionary property, database, and set the defaultBatchLimit to 0 (zero). For example:
    <property name="openjpa.jdbc.DBDictionary" value="db2(defaultBatchLimit=0)"/>

Results

You have now updated the persistence.xml file to enable or disable statement batching, and set the batch limit.



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 2:56:59 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=tejb_jpabatch
File name: tejb_jpabatch.html