Known problems  Importing packages with JRE 1.3

Release Bulletin for jConnect™ for JDBC™ Version 5.5

Using executeBatch

Clients inserting or updating rows with the executeBatch method receive a BatchUpdateException if their code attempts to insert a duplicate-key row. The exception contains an array of update counts. The number of counts can be used to determine how many batch commands were processed prior to the attempted duplicate-key insert; however, the number of counts may not exactly indicate the number of batch commands that executed. For example, a batch containing 50 inserts that failed with a duplicate-key row exception after the 15th insert may have succeeded with 35 inserts.

This discrepancy results from the time elapsed between when jConnect for JDBC encounters a BatchUpdateException and issues a cancel command to the server and when the server processes the cancel command. As in the previous example, jConnect may encounter an exception and issue a cancel command after the 15th insert, but the server might not process the cancel command until after 35 inserts have completed.

Sybase recommends that you execute batch updates and inserts as transactions by setting autoCommit to false and beginning each transaction with Statement.executeUpdate("begin tran"). The transaction should encapsulate all the commands in the batch.

If a BatchUpdateException occurs with the executeBatch method, the client application should roll back the transaction, fix the problem, and retry the transaction. The client can determine the cause of the problem by calling the getNextException method on the BatchUpdateException. The original exception is chained to the BatchUpdateException that jConnect for JDBC generates.

This issue concerns CR #320272. For more information, see Chapter 2, “Programming Information,” in the jConnect for JDBC Programmer’s Reference.





Copyright © 2004. Sybase Inc. All rights reserved. Importing packages with JRE 1.3

View this release bulletin as PDF