类 AbstractFallbackSQLExceptionTranslator
- java.lang.Object
- org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator
- 所有已实现的接口:
SQLExceptionTranslator
- 直接已知子类:
SQLErrorCodeSQLExceptionTranslator,SQLExceptionSubclassTranslator,SQLStateSQLExceptionTranslator
public abstract class AbstractFallbackSQLExceptionTranslator extends Object implements SQLExceptionTranslator
Base class forSQLExceptionTranslatorimplementations that allow for fallback to some otherSQLExceptionTranslator.- 从以下版本开始:
- 2.5.6
- 作者:
- Juergen Hoeller
构造器概要
构造器 构造器 说明 AbstractFallbackSQLExceptionTranslator()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected StringbuildMessage(String task, String sql, SQLException ex)Build a messageStringfor the givenSQLException.protected abstract DataAccessExceptiondoTranslate(String task, String sql, SQLException ex)Template method for actually translating the given exception.SQLExceptionTranslatorgetFallbackTranslator()Return the fallback exception translator, if any.voidsetFallbackTranslator(SQLExceptionTranslator fallback)Override the default SQL state fallback translator (typically aSQLStateSQLExceptionTranslator).DataAccessExceptiontranslate(String task, String sql, SQLException ex)Pre-checks the arguments, callsdoTranslate(java.lang.String, java.lang.String, java.sql.SQLException), and invokes thefallback translatorif necessary.
构造器详细资料
AbstractFallbackSQLExceptionTranslator
public AbstractFallbackSQLExceptionTranslator()
方法详细资料
setFallbackTranslator
public void setFallbackTranslator(SQLExceptionTranslator fallback)
Override the default SQL state fallback translator (typically aSQLStateSQLExceptionTranslator).
getFallbackTranslator
public SQLExceptionTranslator getFallbackTranslator()
Return the fallback exception translator, if any.
translate
public DataAccessException translate(String task, String sql, SQLException ex)
Pre-checks the arguments, callsdoTranslate(java.lang.String, java.lang.String, java.sql.SQLException), and invokes thefallback translatorif necessary.- 指定者:
translate在接口中SQLExceptionTranslator- 参数:
task- readable text describing the task being attemptedsql- the SQL query or update that caused the problem (if known)ex- the offendingSQLException- 返回:
- the DataAccessException wrapping the
SQLException, ornullif no translation could be applied (in a custom translator; the default translators always throw anUncategorizedSQLExceptionin such a case) - 另请参阅:
NestedRuntimeException.getRootCause()
doTranslate
protected abstract DataAccessException doTranslate(String task, String sql, SQLException ex)
Template method for actually translating the given exception.The passed-in arguments will have been pre-checked. Furthermore, this method is allowed to return
nullto indicate that no exception match has been found and that fallback translation should kick in.- 参数:
task- readable text describing the task being attemptedsql- the SQL query or update that caused the problem (if known)ex- the offendingSQLException- 返回:
- the DataAccessException, wrapping the
SQLException; ornullif no exception match found
buildMessage
protected String buildMessage(String task, String sql, SQLException ex)
Build a messageStringfor the givenSQLException.To be called by translator subclasses when creating an instance of a generic
DataAccessExceptionclass.- 参数:
task- readable text describing the task being attemptedsql- the SQL statement that caused the problemex- the offendingSQLException- 返回:
- the message
Stringto use