Skip to content

Most visited

Recently visited

navigation
Added in API level 1

BatchUpdateException

public class BatchUpdateException
extends SQLException implements Serializable

java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Exception
       ↳ java.sql.SQLException
         ↳ java.sql.BatchUpdateException


This exception is thrown if a problem occurs during a batch update operation.

A BatchUpdateException provides additional information about the problem that occurred, compared with a standard SQLException. It supplies update counts for successful commands which were executed before the exception was encountered.

The element order in the array of update counts matches the order that the commands were added to the batch operation.

Once a batch update command fails and a BatchUpdateException is thrown, the JDBC driver may continue processing the remaining commands in the batch. If the driver does process more commands after the problem occurs, the array returned by BatchUpdateException.getUpdateCounts has an element for every command in the batch, not only those that executed successfully. In this case, the array element for any command which encountered a problem is set to Statement.EXECUTE_FAILED.

Summary

Public constructors

BatchUpdateException()

Creates a default BatchUpdateException with the parameters reason, SQLState, and update counts set to null and the vendor code set to 0.

BatchUpdateException(Throwable cause)

Creates an BatchUpdateException object.

BatchUpdateException(int[] updateCounts, Throwable cause)

Creates an BatchUpdateException object.

BatchUpdateException(String reason, int[] updateCounts, Throwable cause)

Creates an BatchUpdateException object.

BatchUpdateException(String reason, String SQLState, int[] updateCounts, Throwable cause)

Creates an BatchUpdateException object.

BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts, Throwable cause)

Creates an BatchUpdateException object.

BatchUpdateException(int[] updateCounts)

Creates a BatchUpdateException with the updateCounts set to the supplied value.

BatchUpdateException(String reason, int[] updateCounts)

Creates a BatchUpdateException with the updateCounts and reason set to the supplied values.

BatchUpdateException(String reason, String SQLState, int[] updateCounts)

Creates a BatchUpdateException with the reason, SQLState and updateCounts set to the supplied values.

BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts)

Creates a BatchUpdateException for the case where all relevant information is provided.

Public methods

int[] getUpdateCounts()

Gets the update count array giving status information for every command that was attempted in the batch.

Inherited methods

From class java.sql.SQLException
From class java.lang.Throwable
From class java.lang.Object
From interface java.lang.Iterable

Public constructors

BatchUpdateException

Added in API level 1
BatchUpdateException ()

Creates a default BatchUpdateException with the parameters reason, SQLState, and update counts set to null and the vendor code set to 0.

BatchUpdateException

Added in API level 9
BatchUpdateException (Throwable cause)

Creates an BatchUpdateException object. The reason is set to null if cause == null otherwise to cause.toString(), and the cause Throwable object is set to the given cause Throwable object.

Parameters
cause Throwable: the Throwable object for the underlying reason this SQLException

BatchUpdateException

Added in API level 9
BatchUpdateException (int[] updateCounts, 
                Throwable cause)

Creates an BatchUpdateException object. The Reason string is set to the null if cause == null otherwise to cause.toString(), and the cause Throwable object is set to the given cause Throwable object. SQLState is initialized to null while vendorCode is zero.

Parameters
updateCounts int
cause Throwable: the Throwable object for the underlying reason this SQLException

BatchUpdateException

Added in API level 9
BatchUpdateException (String reason, 
                int[] updateCounts, 
                Throwable cause)

Creates an BatchUpdateException object. The cause Throwable object is set to the given cause Throwable object. SQLState is initialized to null while vendorCode is zero.

Parameters
reason String
updateCounts int
cause Throwable: the Throwable object for the underlying reason this SQLException

BatchUpdateException

Added in API level 9
BatchUpdateException (String reason, 
                String SQLState, 
                int[] updateCounts, 
                Throwable cause)

Creates an BatchUpdateException object. The cause Throwable object is set to the given cause Throwable object and the updateCounts array set to the int array parameter. SQLState is initialized to null while vendorCode is zero.

Parameters
reason String
SQLState String
updateCounts int
cause Throwable: the Throwable object for the underlying reason this SQLException

BatchUpdateException

Added in API level 9
BatchUpdateException (String reason, 
                String SQLState, 
                int vendorCode, 
                int[] updateCounts, 
                Throwable cause)

Creates an BatchUpdateException object. The cause Throwable object is set to the given cause Throwable object and the updateCounts array set to the int array parameter. VendorCode is set to the given vendorCode. SQLState is initialized to null while vendorCode is zero.

Parameters
reason String
SQLState String
vendorCode int
updateCounts int
cause Throwable: the Throwable object for the underlying reason this SQLException

BatchUpdateException

Added in API level 1
BatchUpdateException (int[] updateCounts)

Creates a BatchUpdateException with the updateCounts set to the supplied value. All other fields are set to their default values.

Parameters
updateCounts int: the array of updateCounts giving the number of successful updates (or another status code) for each command in the batch that was attempted.

BatchUpdateException

Added in API level 1
BatchUpdateException (String reason, 
                int[] updateCounts)

Creates a BatchUpdateException with the updateCounts and reason set to the supplied values. All other fields are set to their default values.

Parameters
reason String: the message providing information about the source of this exception.
updateCounts int: the array of updateCounts giving the number of successful updates (or another status code) for each command in the batch that was attempted.

BatchUpdateException

Added in API level 1
BatchUpdateException (String reason, 
                String SQLState, 
                int[] updateCounts)

Creates a BatchUpdateException with the reason, SQLState and updateCounts set to the supplied values. All other fields are set to their default values.

Parameters
reason String: the message providing information about the source of this exception.
SQLState String: the X/OPEN value to use for the SQLState
updateCounts int: the array of updateCounts giving the number of successful updates (or another status code) for each command in the batch that was attempted.

BatchUpdateException

Added in API level 1
BatchUpdateException (String reason, 
                String SQLState, 
                int vendorCode, 
                int[] updateCounts)

Creates a BatchUpdateException for the case where all relevant information is provided.

Parameters
reason String: the message providing information about the source of this exception.
SQLState String: the X/OPEN value to use for the SQLState.
vendorCode int: the value to use for the vendor error code.
updateCounts int: the array of updateCounts giving the number of successful updates (or another status code) for each command in the batch that was attempted.

Public methods

getUpdateCounts

Added in API level 1
int[] getUpdateCounts ()

Gets the update count array giving status information for every command that was attempted in the batch.

If a batch update command fails and a BatchUpdateException is thrown, the JDBC driver may continue processing the remaining commands in the batch. If the driver does so, the array returned by BatchUpdateException.getUpdateCounts has an element for every command in the batch, not only those that executed successfully. In this case, the array element for any command which encountered a problem is set to Statement.EXECUTE_FAILED.

Returns
int[] an array that contains the successful update counts, before this exception was thrown. Alternatively, if the driver continues to process commands following an error, for each successive command there is a corresponding element in the array giving one of the following status values:
  1. the number of successful updates
  2. Statement.SUCCESS_NO_INFO indicating that the command completed successfully, but the amount of altered rows is unknown.
  3. Statement.EXECUTE_FAILED indicating that the command was unsuccessful.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.