|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
public class SQLStateSQLExceptionTranslator
SQLExceptionTranslator
implementation that analyzes the SQL state
in the SQLException
.
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
Field Summary | |
---|---|
protected Log |
logger
Logger available to subclasses |
Constructor Summary | |
---|---|
SQLStateSQLExceptionTranslator()
|
Method Summary | |
---|---|
protected String |
buildMessage(String task,
String sql,
SQLException ex)
Build a message String for the given SQLException . |
DataAccessException |
translate(String task,
String sql,
SQLException ex)
Translate the given SQLException into a generic DataAccessException . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Log logger
Constructor Detail |
---|
public SQLStateSQLExceptionTranslator()
Method Detail |
---|
public DataAccessException translate(String task, String sql, SQLException ex)
SQLExceptionTranslator
SQLException
into a generic DataAccessException
.
The returned DataAccessException is supposed to contain the original
SQLException
as root cause. However, client code may not generally
rely on this due to DataAccessExceptions possibly being caused by other resource
APIs as well. That said, a getRootCause() instanceof SQLException
check (and subsequent cast) is considered reliable when expecting JDBC-based
access to have happened.
translate
in interface SQLExceptionTranslator
task
- readable text describing the task being attemptedsql
- SQL query or update that caused the problem (may be null
)ex
- the offending SQLException
SQLException
NestedRuntimeException.getRootCause()
protected String buildMessage(String task, String sql, SQLException ex)
String
for the given SQLException
.
Called when creating an instance of a generic
DataAccessException
class.
task
- readable text describing the task being attemptedsql
- the SQL statement that caused the problem. May be null
.ex
- the offending SQLException
String
to use
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |