|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.dao.support.DaoSupport org.springframework.jdbc.core.support.JdbcDaoSupport
public abstract class JdbcDaoSupport
Convenient super class for JDBC data access objects. Requires a DataSource to be set, providing a JdbcTemplate based on it to subclasses.
This base class is mainly intended for JdbcTemplate usage but can also be used when working with DataSourceUtils directly or with org.springframework.jdbc.object classes.
setDataSource(javax.sql.DataSource)
,
JdbcTemplate
,
DataSourceUtils
Field Summary |
---|
Fields inherited from class org.springframework.dao.support.DaoSupport |
---|
logger |
Constructor Summary | |
---|---|
JdbcDaoSupport()
|
Method Summary | |
---|---|
protected void |
checkDaoConfig()
Abstract subclasses must override this to check their configuration. |
protected void |
closeConnectionIfNecessary(Connection con)
Deprecated. in favor of releaseConnection |
protected JdbcTemplate |
createJdbcTemplate(DataSource dataSource)
Create a JdbcTemplate for the given DataSource. |
protected Connection |
getConnection()
Get a JDBC Connection, either from the current transaction or a new one. |
DataSource |
getDataSource()
Return the JDBC DataSource used by this DAO. |
protected SQLExceptionTranslator |
getExceptionTranslator()
Return the SQLExceptionTranslator of this DAO's JdbcTemplate, for translating SQLExceptions in custom JDBC access code. |
JdbcTemplate |
getJdbcTemplate()
Return the JdbcTemplate for this DAO, pre-initialized with the DataSource or set explicitly. |
protected void |
releaseConnection(Connection con)
Close the given JDBC Connection, created via this DAO's DataSource, if it isn't bound to the thread. |
void |
setDataSource(DataSource dataSource)
Set the JDBC DataSource to be used by this DAO. |
void |
setJdbcTemplate(JdbcTemplate jdbcTemplate)
Set the JdbcTemplate for this DAO explicitly, as an alternative to specifying a DataSource. |
Methods inherited from class org.springframework.dao.support.DaoSupport |
---|
afterPropertiesSet, initDao |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JdbcDaoSupport()
Method Detail |
---|
public final void setDataSource(DataSource dataSource)
protected JdbcTemplate createJdbcTemplate(DataSource dataSource)
Can be overridden in subclasses to provide a JdbcTemplate instance with different configuration, or a custom JdbcTemplate subclass.
dataSource
- the JDBC DataSource to create a JdbcTemplate for
setDataSource(javax.sql.DataSource)
public final DataSource getDataSource()
public final void setJdbcTemplate(JdbcTemplate jdbcTemplate)
public final JdbcTemplate getJdbcTemplate()
protected final void checkDaoConfig()
DaoSupport
Implementors should be marked as final
, to make it clear that
concrete subclasses are not supposed to override this template method themselves.
checkDaoConfig
in class DaoSupport
protected final Connection getConnection() throws CannotGetJdbcConnectionException
CannotGetJdbcConnectionException
- if the attempt to get a Connection failedDataSourceUtils.getConnection(javax.sql.DataSource)
protected final SQLExceptionTranslator getExceptionTranslator()
JdbcAccessor.getExceptionTranslator()
protected final void closeConnectionIfNecessary(Connection con)
releaseConnection(java.sql.Connection)
protected final void releaseConnection(Connection con)
con
- Connection to closeDataSourceUtils.releaseConnection(java.sql.Connection, javax.sql.DataSource)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |