类 DelegatingDataSource
- java.lang.Object
- org.springframework.jdbc.datasource.DelegatingDataSource
- 所有已实现的接口:
Wrapper,CommonDataSource,DataSource,InitializingBean
- 直接已知子类:
LazyConnectionDataSourceProxy,TransactionAwareDataSourceProxy,UserCredentialsDataSourceAdapter
public class DelegatingDataSource extends Object implements DataSource, InitializingBean
JDBCDataSourceimplementation that delegates all calls to a given targetDataSource.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.- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
getConnection()
构造器概要
构造器 构造器 说明 DelegatingDataSource()Create a new DelegatingDataSource.DelegatingDataSource(DataSource targetDataSource)Create a new DelegatingDataSource.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.ConnectiongetConnection()ConnectiongetConnection(String username, String password)intgetLoginTimeout()PrintWritergetLogWriter()LoggergetParentLogger()DataSourcegetTargetDataSource()Return the target DataSource that this DataSource should delegate to.booleanisWrapperFor(Class<?> iface)protected DataSourceobtainTargetDataSource()Obtain the targetDataSourcefor actual use (nevernull).voidsetLoginTimeout(int seconds)voidsetLogWriter(PrintWriter out)voidsetTargetDataSource(DataSource targetDataSource)Set the target DataSource that this DataSource should delegate to.<T> Tunwrap(Class<T> iface)从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 javax.sql.CommonDataSource
createShardingKeyBuilder
从接口继承的方法 javax.sql.DataSource
createConnectionBuilder
构造器详细资料
DelegatingDataSource
public DelegatingDataSource()
Create a new DelegatingDataSource.
DelegatingDataSource
public DelegatingDataSource(DataSource targetDataSource)
Create a new DelegatingDataSource.- 参数:
targetDataSource- the target DataSource
方法详细资料
setTargetDataSource
public void setTargetDataSource(@Nullable DataSource targetDataSource)
Set the target DataSource that this DataSource should delegate to.
getTargetDataSource
@Nullable public DataSource getTargetDataSource()
Return the target DataSource that this DataSource should delegate to.
obtainTargetDataSource
protected DataSource obtainTargetDataSource()
Obtain the targetDataSourcefor actual use (nevernull).- 从以下版本开始:
- 5.0
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet在接口中InitializingBean
getConnection
public Connection getConnection() throws SQLException
- 指定者:
getConnection在接口中DataSource- 抛出:
SQLException
getConnection
public Connection getConnection(String username, String password) throws SQLException
- 指定者:
getConnection在接口中DataSource- 抛出:
SQLException
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- 指定者:
getLogWriter在接口中CommonDataSource- 指定者:
getLogWriter在接口中DataSource- 抛出:
SQLException
setLogWriter
public void setLogWriter(PrintWriter out) throws SQLException
- 指定者:
setLogWriter在接口中CommonDataSource- 指定者:
setLogWriter在接口中DataSource- 抛出:
SQLException
getLoginTimeout
public int getLoginTimeout() throws SQLException
- 指定者:
getLoginTimeout在接口中CommonDataSource- 指定者:
getLoginTimeout在接口中DataSource- 抛出:
SQLException
setLoginTimeout
public void setLoginTimeout(int seconds) throws SQLException
- 指定者:
setLoginTimeout在接口中CommonDataSource- 指定者:
setLoginTimeout在接口中DataSource- 抛出:
SQLException
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- 指定者:
unwrap在接口中Wrapper- 抛出:
SQLException
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- 指定者:
isWrapperFor在接口中Wrapper- 抛出:
SQLException
getParentLogger
public Logger getParentLogger()
- 指定者:
getParentLogger在接口中CommonDataSource