Package org.springframework.jdbc.support
Interface SQLExceptionTranslator
- All Known Implementing Classes:
- AbstractFallbackSQLExceptionTranslator,- SQLErrorCodeSQLExceptionTranslator,- SQLExceptionSubclassTranslator,- SQLStateSQLExceptionTranslator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy interface for translating between 
SQLExceptions
 and Spring's data access strategy-agnostic DataAccessException
 hierarchy.
 Implementations can be generic (for example, using
 SQLState codes for JDBC) or wholly
 proprietary (for example, using Oracle error codes) for greater precision.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptiontranslate(String task, String sql, SQLException ex) Translate the givenSQLExceptioninto a genericDataAccessException.
- 
Method Details- 
translateTranslate the givenSQLExceptioninto a genericDataAccessException.The returned DataAccessException is supposed to contain the original SQLExceptionas 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, agetRootCause() instanceof SQLExceptioncheck (and subsequent cast) is considered reliable when expecting JDBC-based access to have happened.- Parameters:
- task- readable text describing the task being attempted
- sql- the SQL query or update that caused the problem (if known)
- ex- the offending- SQLException
- Returns:
- the DataAccessException wrapping the SQLException, ornullif no specific translation could be applied
- See Also:
 
 
-