|
|
JDBC 2 and Batch Update Operations
JDBC 2 provides support for batch update operations. The BatchUpdateException class provides information about errors that occur during a batch update using the Statement method executeBatch.
The class inherits all the method from the class SQLException and also the method getUpdateCounts which returns an array of update counts for those commands in the batch that were executed successfully before the error was encountered.
try { ... } catch(BatchUpdateException bue) { System.err.println("\n*** BatchUpdateException:\n"); int [] affectedCount = bue.getUpdateCounts(); for (int i = 0; i < affectedCount.length; i++) { System.err.print(affectedCount[i] + " "); } System.err.println(); System.err.println("Message: " + bue.getMessage()); System.err.println("SQLState: " + bue.getSQLState()); System.err.println("NativeError: " + bue.getErrorCode()); System.err.println(); SQLException sqe = bue.getNextException(); while (sqe != null) { System.err.println("Message: " + sqe.getMessage()); System.err.println("SQLState: " + sqe.getSQLState()); System.err.println("NativeError: " + sqe.getErrorCode()); System.err.println(); sqe = sqe.getNextException(); } }Note: The BatchUpdateException object points to a chain of SQLException objects.
|
Upright Database Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 dbtechnology@upright.se |
|
|