IBM Support

Batch size limit when using Db2 Universal JDBC Driver is 32K due to limitation of DRDA architecture

Question & Answer


Question

This document provides troubleshooting information for a DRDA® error that appears after you update about 35000 rows when performing batch updates using the Db2® Universal JDBC Driver.

Cause

The problem occurs due to DRDA limitation. In DRDA, every chained request must have a unique correlation id. The correlation ID is a 2 byte field, allowing the maximum number of unique correlation ids generated to be 32K. This is the current limitation of the DRDA architecture and is a known limitation of the Db2 Universal JDBC Driver in Db2 Universal Database™ (Db2 UDB) Version 8. It is fixed in the IBM® Db2 Driver for JDBC and SQLJ in Db2 Version 9.


Problem details
An example of the error message that is returned to the JDBC driver at the time of the problem is as follows:
"Execution failed due to a distribution protocol error that caused deallocation of the conversation. A DRDA Data Stream Syntax Error was detected. Reason: 0x13"

An example of code that can return this error message is as follows:


String stmt = "insert into batchtab values( ? )";

PreparedStatement prestmt = conn.prepareStatement(stmt);

for (int j=0;j < batchNumber; i++ ) {
pstmt.setInt(1,i);
pstmt.addBatch();
}

pstmt.executeBatch();
pstmt.close();


This application would report the problem as follows:
SQLSTATE : 58009
ErrorCode : -4499
Localized Message : Error for batch element #32765: Execution failed due to a distribution protocol error that caused deallocation of the conversation. A DRDA Data Stream Syntax Error was detected. Reason: 0x13

com.ibm.Db2.jcc.b.DisconnectException: Error for batch element #32764:
Execution failed due to a distribution protocol error that caused
deallocation of the conversation. A DRDA Data Stream Syntax Error was
detected. Reason: 0x13
at com.ibm.Db2.jcc.a.ab.l(ab.java:1214)
at com.ibm.Db2.jcc.a.ab.c(ab.java(Compiled Code))
at com.ibm.Db2.jcc.a.ab.v(ab.java(Inlined Compiled Code))
at com.ibm.Db2.jcc.a.db.a(db.java(Compiled Code))
at com.ibm.Db2.jcc.a.r.a(r.java(Inlined Compiled Code))
at com.ibm.Db2.jcc.a.tb.c(tb.java(Inlined Compiled Code))
at com.ibm.Db2.jcc.b.ad.Z(ad.java(Inlined Compiled Code))
at com.ibm.Db2.jcc.b.ad.b(ad.java(Compiled Code))
at com.ibm.Db2.jcc.b.ad.a(ad.java:2632)
at com.ibm.Db2.jcc.b.ad.executeBatch(ad.java:2444)
at com.ibm.Db2.jcc.b.ad.executeBatch(ad.java:1329)

Answer

If the database server is Db2 Version 9 and higher for Linux, UNIX and Windows, there is no limit of 32K on the number of statements in a batch. There is also no such limit when the database server is Informix Dynamic Server, or it is Db2 on iSeries V7R1 and higher.
 
If the database server is Db2 Version 9 and higher on zOS, the number of statements in a batch is not limited to 32K if they are all INSERT or MERGE statements. The number of DELETE and UPDATE statements in a batch is limited to 32K.
 
To work around this issue, when using a database server for which the a number of statements in a
 batch is limited to 32K, keep track of the batch elements in the application, then issue an execute command before the 32K limit is reached.

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Connectivity - DRDA","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1","Edition":"Enterprise Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21251923