org.springframework.jdbc.support
Class SQLStateSQLExceptionTranslator
java.lang.Object
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
- All Implemented Interfaces:
- SQLExceptionTranslator
public class SQLStateSQLExceptionTranslator
- extends Object
- implements SQLExceptionTranslator
Implementation of SQLExceptionTranslator that analyzes the SQL state
in the SQLException.
Not able to diagnose all problems, but is portable between databases and
does need require special initialization (no database vendor detection etc).
For more precise translation, consider SQLErrorCodeSQLExceptionTranslator.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
SQLException.getSQLState()
,
SQLErrorCodeSQLExceptionTranslator
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected final Log logger
SQLStateSQLExceptionTranslator
public SQLStateSQLExceptionTranslator()
translate
public DataAccessException translate(String task,
String sql,
SQLException sqlEx)
- Description copied from interface:
SQLExceptionTranslator
- Translate the given SQL exception into a generic
data access exception.
- Specified by:
translate
in interface SQLExceptionTranslator
- Parameters:
task
- readable text describing the task being attemptedsql
- SQL query or update that caused the problem. May be null
.sqlEx
- the offending SQLException
- Returns:
- the DataAccessException to throw
buildMessage
protected String buildMessage(String task,
String sql,
SQLException sqlEx)
- Build a message String for the given SQLException.
Called when creating an instance of a generic DataAccessException class.
- Parameters:
task
- readable text describing the task being attemptedsql
- SQL query or update that caused the problem. May be null
.sqlEx
- the offending SQLException
- Returns:
- the message String to use
Copyright (c) 2002-2007 The Spring Framework Project.