Class JdbcAccessor
java.lang.Object
org.springframework.jdbc.support.JdbcAccessor
- All Implemented Interfaces:
- InitializingBean
- Direct Known Subclasses:
- JdbcTemplate
Base class for 
JdbcTemplate and
 other JDBC-accessing DAO helpers, defining common properties such as
 DataSource and exception translator.
 Not intended to be used directly.
 See JdbcTemplate.
- Since:
- 28.11.2003
- Author:
- Juergen Hoeller, Sebastien Deleuze
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger available to subclasses.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidEagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.Return the DataSource used by this template.Return the exception translator to use for this instance, creating a default if necessary.booleanReturn whether to lazily initialize the SQLExceptionTranslator for this accessor.protected DataSourceObtain the DataSource for actual use.voidsetDatabaseProductName(String dbName) Specify the database product name for theDataSourcethat this accessor uses.voidsetDataSource(@Nullable 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.
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log loggerLogger available to subclasses.
 
- 
- 
Constructor Details- 
JdbcAccessorpublic JdbcAccessor()
 
- 
- 
Method Details- 
setDataSourceSet the JDBC DataSource to obtain connections from.
- 
getDataSourceReturn the DataSource used by this template.
- 
obtainDataSourceObtain the DataSource for actual use.- Returns:
- the DataSource (never null)
- Throws:
- IllegalStateException- in case of no DataSource set
- Since:
- 5.0
 
- 
setDatabaseProductNameSpecify the database product name for theDataSourcethat this accessor uses. This allows for initializing aSQLErrorCodeSQLExceptionTranslatorwithout obtaining aConnectionfrom theDataSourceto get the meta-data.- Parameters:
- dbName- the database product name that identifies the error codes entry
- See Also:
 
- 
setExceptionTranslatorSet the exception translator for this instance.A SQLErrorCodeSQLExceptionTranslatorused by default if a user-provided `sql-error-codes.xml` file has been found in the root of the classpath. Otherwise,SQLExceptionSubclassTranslatorserves as the default translator as of 6.0.- See Also:
 
- 
getExceptionTranslatorReturn the exception translator to use for this instance, creating a default if necessary.- See Also:
 
- 
setLazyInitpublic 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.- See Also:
 
- 
isLazyInitpublic boolean isLazyInit()Return whether to lazily initialize the SQLExceptionTranslator for this accessor.- See Also:
 
- 
afterPropertiesSetpublic void afterPropertiesSet()Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.- Specified by:
- afterPropertiesSetin interface- InitializingBean
 
 
-