SQLExceptionTranslator implementation that analyzes the SQL state in
the SQLException based on the first two digits (the SQL state "class").
Detects standard SQL state values and well-known vendor-specific SQL states.
Not able to diagnose all problems, but is portable between databases and
does not require special initialization (no database vendor detection, etc.).
For more precise translation, consider SQLErrorCodeSQLExceptionTranslator.
This translator is commonly used as a fallback
behind a primary translator such as SQLErrorCodeSQLExceptionTranslator or
SQLExceptionSubclassTranslator.
java.sql.SQLException#getSQLState() , SQLErrorCodeSQLExceptionTranslator, SQLExceptionSubclassTranslator
| Modifier and Type | Field and Description |
|---|---|
| private static final Set | |
| private static final Set | |
| private static final Set | |
| private static final Set | |
| private static final Set | |
| private static final Set |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected DataAccessException | doTranslate(String
readable text describing the task being attempted task, String the SQL query or update that caused the problem (if known) sql, SQLException the offending ex)SQLExceptionImplements abstract org. |
| private String | Returns: the SQL state codethe exception from which the ex)SQL state
is to be extractedGets the SQL state code from the supplied |
| pack-priv static boolean | indicatesCannotAcquireLock(String
the SQL state value sqlState)Check whether the given SQL state indicates a |
| pack-priv static boolean | indicatesDuplicateKey(String
the SQL state value sqlState, int the error code errorCode)Check whether the given SQL state and the associated error code (in case
of a generic SQL state value) indicate a |
| BAD_SQL_GRAMMAR_CODES | back to summary |
|---|---|
| private static final Set<String> BAD_SQL_GRAMMAR_CODES | |
| DATA_ACCESS_RESOURCE_FAILURE_CODES | back to summary |
|---|---|
| private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES | |
| DATA_INTEGRITY_VIOLATION_CODES | back to summary |
|---|---|
| private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES | |
| DUPLICATE_KEY_ERROR_CODES | back to summary |
|---|---|
| private static final Set<Integer> DUPLICATE_KEY_ERROR_CODES | |
| PESSIMISTIC_LOCKING_FAILURE_CODES | back to summary |
|---|---|
| private static final Set<String> PESSIMISTIC_LOCKING_FAILURE_CODES | |
| TRANSIENT_DATA_ACCESS_RESOURCE_CODES | back to summary |
|---|---|
| private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES | |
| SQLStateSQLExceptionTranslator | back to summary |
|---|---|
| public SQLStateSQLExceptionTranslator() | |
| doTranslate | back to summary |
|---|---|
| protected DataAccessException doTranslate(String task, String sql, SQLException ex) Implements abstract org. Doc from org. Template method for actually translating the given exception. The passed-in arguments will have been pre-checked. Furthermore, this method
is allowed to return
| |
| getSqlState | back to summary |
|---|---|
| private String getSqlState(SQLException ex) Gets the SQL state code from the supplied Some JDBC drivers nest the actual exception from a batched update, so we might need to dig down into the nested exception.
| |
| indicatesCannotAcquireLock | back to summary |
|---|---|
| pack-priv static boolean indicatesCannotAcquireLock(String sqlState) Check whether the given SQL state indicates a
| |
| indicatesDuplicateKey | back to summary |
|---|---|
| pack-priv static boolean indicatesDuplicateKey(String sqlState, int errorCode) Check whether the given SQL state and the associated error code (in case
of a generic SQL state value) indicate a
| |