public class DelegatingDataSource extends java.lang.Object implements javax.sql.DataSource, InitializingBean
DataSource implementation that delegates all calls
to a given target DataSource.
This class is meant to be subclassed, with subclasses overriding only
those methods (such as getConnection()) that should not simply
delegate to the target DataSource.
getConnection()| Constructor and Description |
|---|
DelegatingDataSource()
Create a new DelegatingDataSource.
|
DelegatingDataSource(javax.sql.DataSource targetDataSource)
Create a new DelegatingDataSource.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc. |
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
javax.sql.DataSource |
getTargetDataSource()
Return the target DataSource that this DataSource should delegate to.
|
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setTargetDataSource(javax.sql.DataSource targetDataSource)
Set the target DataSource that this DataSource should delegate to.
|
<T> T |
unwrap(java.lang.Class<T> iface) |
public DelegatingDataSource()
public DelegatingDataSource(javax.sql.DataSource targetDataSource)
targetDataSource - the target DataSourcepublic void setTargetDataSource(javax.sql.DataSource targetDataSource)
public javax.sql.DataSource getTargetDataSource()
public void afterPropertiesSet()
InitializingBeanBeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet in interface InitializingBeanpublic java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic java.sql.Connection getConnection(java.lang.String username,
java.lang.String password)
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLogWriter(java.io.PrintWriter out)
throws java.sql.SQLException
setLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLoginTimeout(int seconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic java.util.logging.Logger getParentLogger()
getParentLogger in interface javax.sql.CommonDataSource