public abstract class JdbcAccessor extends Object implements InitializingBean
JdbcTemplate
and
other JDBC-accessing DAO helpers, defining common properties such as
DataSource and exception translator.
Not intended to be used directly.
See JdbcTemplate
.
JdbcTemplate
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Logger available to subclasses
|
Constructor and Description |
---|
JdbcAccessor() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Eagerly initialize the exception translator, if demanded,
creating a default one for the specified DataSource if none set.
|
DataSource |
getDataSource()
Return the DataSource used by this template.
|
SQLExceptionTranslator |
getExceptionTranslator()
Return the exception translator for this instance.
|
boolean |
isLazyInit()
Return whether to lazily initialize the SQLExceptionTranslator for this accessor.
|
void |
setDatabaseProductName(String dbName)
Specify the database product name for the DataSource that this accessor uses.
|
void |
setDataSource(DataSource dataSource)
Set the JDBC DataSource to obtain connections from.
|
void |
setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator for this instance.
|
void |
setLazyInit(boolean lazyInit)
Set whether to lazily initialize the SQLExceptionTranslator for this accessor,
on first encounter of a SQLException.
|
protected final Log logger
public void setDataSource(DataSource dataSource)
public DataSource getDataSource()
public void setDatabaseProductName(String dbName)
dbName
- the database product name that identifies the error codes entrySQLErrorCodeSQLExceptionTranslator.setDatabaseProductName(java.lang.String)
,
DatabaseMetaData.getDatabaseProductName()
public void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
If no custom translator is provided, a default
SQLErrorCodeSQLExceptionTranslator
is used
which examines the SQLException's vendor-specific error code.
public SQLExceptionTranslator getExceptionTranslator()
Creates a default SQLErrorCodeSQLExceptionTranslator
for the specified DataSource if none set, or a
SQLStateSQLExceptionTranslator
in case of no DataSource.
getDataSource()
public void setLazyInit(boolean lazyInit)
Early initialization just applies if afterPropertiesSet()
is called.
getExceptionTranslator()
,
afterPropertiesSet()
public boolean isLazyInit()
getExceptionTranslator()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean