|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
Implementation of SQLExceptionTranslator that uses specific vendor codes. More precise than SQLState implementation, but vendor-specific.
This class applies the following matching rules:
SQLErrorCodesFactory
Field Summary | |
protected Log |
logger
|
protected SQLErrorCodes |
sqlErrorCodes
Error codes available to subclasses |
Constructor Summary | |
SQLErrorCodeSQLExceptionTranslator()
Constructor for use as a JavaBean. |
|
SQLErrorCodeSQLExceptionTranslator(DataSource ds)
Create a SQLErrorCode translator for the given DataSource. |
|
SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec)
Create a SQLErrorCode translator given these error codes. |
Method Summary | |
protected DataAccessException |
customTranslate(String task,
String sql,
SQLException sqlex)
Subclasses can override this method to attempt a custom mapping from SQLException to DataAccessException. |
void |
setDataSource(DataSource ds)
Set the DataSource. |
void |
setFallbackTranslator(SQLExceptionTranslator fallback)
Override the default SQLState fallback translator |
void |
setSqlErrorCodes(SQLErrorCodes sec)
Set custom error codes to be used for translation |
DataAccessException |
translate(String task,
String sql,
SQLException sqlex)
Translate the given SQL exception into a generic data access exception. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Log logger
protected SQLErrorCodes sqlErrorCodes
Constructor Detail |
public SQLErrorCodeSQLExceptionTranslator()
public SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec)
sec
- error codespublic SQLErrorCodeSQLExceptionTranslator(DataSource ds)
ds
- DataSource to use to find metadata and establish which error
codes are usableMethod Detail |
public void setSqlErrorCodes(SQLErrorCodes sec)
sec
- custom error codes to usepublic void setDataSource(DataSource ds)
Setting this property will cause a connection to be obtained from the DataSource to get the metadata.
ds
- DataSource to use to find metadata and establish which error
codes are usablepublic void setFallbackTranslator(SQLExceptionTranslator fallback)
fallback
- custom fallback exception translator to use if error code
translation failspublic DataAccessException translate(String task, String sql, SQLException sqlex)
SQLExceptionTranslator
translate
in interface SQLExceptionTranslator
task
- readable text describing the task being attemptedsql
- SQL query or update that caused the problem.
May be null.sqlex
- SQLException encountered by JDBC implementationprotected DataAccessException customTranslate(String task, String sql, SQLException sqlex)
task
- task being attemptedsql
- SQL that caused the problemsqlex
- offending SQLException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |