public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator
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
.
SQLException.getSQLState()
,
SQLErrorCodeSQLExceptionTranslator
logger
Constructor and Description |
---|
SQLStateSQLExceptionTranslator() |
Modifier and Type | Method and Description |
---|---|
protected DataAccessException |
doTranslate(java.lang.String task,
java.lang.String sql,
java.sql.SQLException ex)
Template method for actually translating the given exception.
|
buildMessage, getFallbackTranslator, setFallbackTranslator, translate
protected DataAccessException doTranslate(java.lang.String task, java.lang.String sql, java.sql.SQLException ex)
AbstractFallbackSQLExceptionTranslator
The passed-in arguments will have been pre-checked. Furthermore, this method
is allowed to return null
to indicate that no exception match has
been found and that fallback translation should kick in.
doTranslate
in class AbstractFallbackSQLExceptionTranslator
task
- readable text describing the task being attemptedsql
- SQL query or update that caused the problem (if known)ex
- the offending SQLException
SQLException
;
or null
if no exception match found