类 JdbcAccessor
- java.lang.Object
- org.springframework.jdbc.support.JdbcAccessor
- 所有已实现的接口:
InitializingBean
- 直接已知子类:
JdbcTemplate
public abstract class JdbcAccessor extends Object implements InitializingBean
Base class forJdbcTemplateand other JDBC-accessing DAO helpers, defining common properties such as DataSource and exception translator.Not intended to be used directly. See
JdbcTemplate.- 从以下版本开始:
- 28.11.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
JdbcTemplate
构造器概要
构造器 构造器 说明 JdbcAccessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.DataSourcegetDataSource()Return the DataSource used by this template.SQLExceptionTranslatorgetExceptionTranslator()Return the exception translator for this instance.booleanisLazyInit()Return whether to lazily initialize the SQLExceptionTranslator for this accessor.protected DataSourceobtainDataSource()Obtain the DataSource for actual use.voidsetDatabaseProductName(String dbName)Specify the database product name for the DataSource that this accessor uses.voidsetDataSource(DataSource dataSource)Set the JDBC DataSource to obtain connections from.voidsetExceptionTranslator(SQLExceptionTranslator exceptionTranslator)Set the exception translator for this instance.voidsetLazyInit(boolean lazyInit)Set whether to lazily initialize the SQLExceptionTranslator for this accessor, on first encounter of an SQLException.
构造器详细资料
JdbcAccessor
public JdbcAccessor()
方法详细资料
setDataSource
public void setDataSource(@Nullable DataSource dataSource)
Set the JDBC DataSource to obtain connections from.
getDataSource
@Nullable public DataSource getDataSource()
Return the DataSource used by this template.
obtainDataSource
protected DataSource obtainDataSource()
Obtain the DataSource for actual use.- 返回:
- the DataSource (never
null) - 抛出:
IllegalStateException- in case of no DataSource set- 从以下版本开始:
- 5.0
setDatabaseProductName
public void setDatabaseProductName(String dbName)
Specify the database product name for the DataSource that this accessor uses. This allows to initialize an SQLErrorCodeSQLExceptionTranslator without obtaining a Connection from the DataSource to get the meta-data.- 参数:
dbName- the database product name that identifies the error codes entry- 另请参阅:
SQLErrorCodeSQLExceptionTranslator.setDatabaseProductName(java.lang.String),DatabaseMetaData.getDatabaseProductName()
setExceptionTranslator
public void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator for this instance.If no custom translator is provided, a default
SQLErrorCodeSQLExceptionTranslatoris used which examines the SQLException's vendor-specific error code.
getExceptionTranslator
public SQLExceptionTranslator getExceptionTranslator()
Return the exception translator for this instance.Creates a default
SQLErrorCodeSQLExceptionTranslatorfor the specified DataSource if none set, or aSQLStateSQLExceptionTranslatorin case of no DataSource.- 另请参阅:
getDataSource()
setLazyInit
public void setLazyInit(boolean lazyInit)
Set whether to lazily initialize the SQLExceptionTranslator for this accessor, on first encounter of an SQLException. Default is "true"; can be switched to "false" for initialization on startup.Early initialization just applies if
afterPropertiesSet()is called.
isLazyInit
public boolean isLazyInit()
Return whether to lazily initialize the SQLExceptionTranslator for this accessor.
afterPropertiesSet
public void afterPropertiesSet()
Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.- 指定者:
afterPropertiesSet在接口中InitializingBean