v The SQLSTATE
getThrowable
Returns a java.lang.Throwable object that caused the SQLException, or null, if
no such object exists.
printTrace
Prints diagnostic information.
SQLException subclasses
If you are using JDBC 4.0 or later, you can obtain more specific information than
an SQLException provides by catching the following exception classes:
v SQLNonTransientException
An SQLNonTransientException is thrown when an SQL operation that failed
previously cannot succeed when the operation is retried, unless some corrective
action is taken. The SQLNonTransientException class has these subclasses:
– SQLFeatureNotSupportedException
– SQLNonTransientConnectionException
– SQLDataException
– SQLIntegrityConstraintViolationException
– SQLInvalidAuthorizationSpecException
– SQLSyntaxException
v SQLTransientException
An SQLTransientException is thrown when an SQL operation that failed
previously might succeed when the operation is retried, without intervention
from the application. A connection is still valid after an SQLTransientException
is thrown. The SQLTransientException class has these subclasses:
– SQLTransientConnectionException
– SQLTransientRollbackException
– SQLTimeoutException
v SQLRecoverableException
An SQLRecoverableException is thrown when an operation that failed previously
might succeed if the application performs some recovery steps, and retries the
transaction. A connection is no longer valid after an SQLRecoverableException is
thrown.
v SQLClientInfoException
A SQLClientInfoException is thrown by the Connection.setClientInfo method
when one or more client properties cannot be set. The SQLClientInfoException
indicates which properties cannot be set.
BatchUpdateException
A BatchUpdateException object contains the following items about an error that
occurs during execution of a batch of SQL statements:
v A String object that contains a description of the error, or null.
v A String object that contains the SQLSTATE for the failing SQL statement, or
null
v An integer value that contains the error code, or zero
v An integer array of update counts for SQL statements in the batch, or null
v A pointer to an SQLException object, or null
One BatchUpdateException is thrown for the entire batch. At least one
SQLException object is chained to the BatchUpdateException object. The
76 Application Programming Guide and Reference for Java
â„¢