|
|||||||||||
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 org.apache.commons.logging.Log |
logger
|
protected SQLErrorCodes |
sqlErrorCodes
Error codes available to subclasses |
Constructor Summary | |
SQLErrorCodeSQLExceptionTranslator()
Constructor for use as a JavaBean. |
|
SQLErrorCodeSQLExceptionTranslator(javax.sql.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(java.lang.String task,
java.lang.String sql,
java.sql.SQLException sqlex)
Subclasses can override this method to attempt a custom mapping from SQLException to DataAccessException |
void |
setDataSource(javax.sql.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(java.lang.String task,
java.lang.String sql,
java.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 org.apache.commons.logging.Log logger
protected SQLErrorCodes sqlErrorCodes
Constructor Detail |
public SQLErrorCodeSQLExceptionTranslator()
public SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec)
sec
- error codespublic SQLErrorCodeSQLExceptionTranslator(javax.sql.DataSource ds)
ds
- DataSource to use to find metadata and establish which error
codes are usableMethod Detail |
public void setDataSource(javax.sql.DataSource ds)
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 void setSqlErrorCodes(SQLErrorCodes sec)
sec
- custom error codes to usepublic DataAccessException translate(java.lang.String task, java.lang.String sql, java.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(java.lang.String task, java.lang.String sql, java.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 |