79 lines
6.7 KiB
HTML
79 lines
6.7 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="concept" />
|
|
<meta name="DC.Title" content="BatchUpdateException" />
|
|
<meta name="abstract" content="An important consideration of batch updates is what action to take when a call to the executeBatch method fails. In this case, a new type of exception, called BatchUpdateException, is thrown. The BatchUpdateException is a subclass of SQLException and it allows you to call all the same methods you have always called to receive the message, the SQLState, and vendor code." />
|
|
<meta name="description" content="An important consideration of batch updates is what action to take when a call to the executeBatch method fails. In this case, a new type of exception, called BatchUpdateException, is thrown. The BatchUpdateException is a subclass of SQLException and it allows you to call all the same methods you have always called to receive the message, the SQLState, and vendor code." />
|
|
<meta name="DC.Relation" scheme="URI" content="batchupd.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="batchstm.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="batchpre.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="batchblo.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="batchexc" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>BatchUpdateException</title>
|
|
</head>
|
|
<body id="batchexc"><a name="batchexc"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">BatchUpdateException</h1>
|
|
<div><p>An important consideration of batch updates is what action to take
|
|
when a call to the executeBatch method fails. In this case, a new type of
|
|
exception, called BatchUpdateException, is thrown. The BatchUpdateException
|
|
is a subclass of SQLException and it allows you to call all the same methods
|
|
you have always called to receive the message, the SQLState, and vendor code.</p>
|
|
<p> BatchUpdateException also provides the getUpdateCounts method that returns
|
|
an integer array. The integer array contains update counts from all the statements
|
|
in the batch that were processed up to the point where the failure occurred.
|
|
The array length tells you which statement in the batch failed. For example,
|
|
if the array returned in the exception has a length of three, the fourth statement
|
|
in the batch failed. Therefore, from the single BatchUpdateException object
|
|
that is returned, you can determine the update counts for all the statements
|
|
that were successful, which statement failed, and all the information about
|
|
the failure.</p>
|
|
<p>The standard performance of processing batched updates is equivalent
|
|
to the performance of processing each statement independently. You can refer
|
|
to <a href="batchblo.htm">Blocked insert support</a> for more information
|
|
on optimized support for batch updates. You should still use the new model
|
|
when coding and take advantage of future performance optimizations.</p>
|
|
<div class="note"><span class="notetitle">Note:</span> In the JDBC 2.1 specification, a different option is provided for how
|
|
exception conditions for batch updates are handled. JDBC 2.1 introduces a
|
|
model where the processing batch continues after a batch entry fails. A special
|
|
update count is placed in the array of update count integers that is returned
|
|
for each entry that fails. This allows large batches to continue processing
|
|
even though one of their entries fails. See the JDBC 2.1 or JDBC 3.0 specification
|
|
for details on these two modes of operation. By default, the native JDBC driver
|
|
uses the JDBC 2.0 definition. The driver provides a <a href="conprop.htm">Connection
|
|
property</a> that is used when using DriverManager to establish connections.
|
|
The driver also provides a <a href="dasrprop.htm">DataSource property</a> that
|
|
is used when using DataSources to establish connections. These properties
|
|
allow applications to choose how they want batch operations to handle failures.</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="batchupd.htm" title="Batch update support allows any updates to the database to be passed as a single transaction between the user program and the database. This procedure can significantly improve performance when many updates must be performed at once.">Batch updates</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="batchblo.htm" title="You can use a blocked insert is an iSeries operation to insert several rows into a database table at a time.">Blocked insert support</a></div>
|
|
</div>
|
|
<div class="relref"><strong>Related reference</strong><br />
|
|
<div><a href="batchstm.htm" title="To perform a Statement batch update, you must turn off auto-commit. In Java Database Connectivity (JDBC), auto-commit is on by default. Auto-commit means any updates to the database are committed after each SQL statement is processed. If you want to treat a group of statements being handed to the database as one functional group, you do not want the database committing each statement individually. If you do not turn off auto-commit and a statement in the middle of the batch fails, you cannot roll back the entire batch and try it again because half of the statements have been made final. Further, the additional work of committing each statement in a batch creates a lot of overhead.">Statement batch update</a></div>
|
|
<div><a href="batchpre.htm" title="A preparedStatement batch is similar to the Statement batch; however, a preparedStatement batch always works off the same prepared statement, and you only change the parameters to that statement.">PreparedStatement batch update</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |