|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.core.support.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 | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
JdbcDaoSupport()
|
Method Summary | |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected void |
closeConnectionIfNecessary(java.sql.Connection con)
Close the given JDBC Connection if necessary, created via this bean's DataSource, if it isn't bound to the thread. |
protected java.sql.Connection |
getConnection()
Get a JDBC Connection, either from the current transaction or a new one. |
protected javax.sql.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. |
protected JdbcTemplate |
getJdbcTemplate()
Return the JdbcTemplate for this DAO, pre-initialized with the DataSource or set explicitly. |
protected void |
initDao()
Subclasses can override this for custom initialization behavior. |
void |
setDataSource(javax.sql.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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public JdbcDaoSupport()
Method Detail |
public final void setDataSource(javax.sql.DataSource dataSource)
protected final javax.sql.DataSource getDataSource()
public final void setJdbcTemplate(JdbcTemplate jdbcTemplate)
protected final JdbcTemplate getJdbcTemplate()
public final void afterPropertiesSet() throws java.lang.Exception
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
java.lang.Exception
- in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.protected void initDao() throws java.lang.Exception
java.lang.Exception
- if initialization failsprotected final java.sql.Connection getConnection() throws CannotGetJdbcConnectionException
CannotGetJdbcConnectionException
- if the attempt to get a Connection failedprotected final SQLExceptionTranslator getExceptionTranslator()
protected final void closeConnectionIfNecessary(java.sql.Connection con) throws CannotCloseJdbcConnectionException
con
- Connection to close
CannotCloseJdbcConnectionException
- if the attempt to close the
Connection failed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |