Class DelegatingDataSource
java.lang.Object
org.springframework.jdbc.datasource.DelegatingDataSource
- All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, InitializingBean
- Direct Known Subclasses:
LazyConnectionDataSourceProxy, ShardingKeyDataSourceAdapter, TransactionAwareDataSourceProxy, UserCredentialsDataSourceAdapter
JDBC
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.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new DelegatingDataSource.DelegatingDataSource(DataSource targetDataSource) Create a new DelegatingDataSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.getConnection(String username, String password) intReturn the target DataSource that this DataSource should delegate to.booleanisWrapperFor(Class<?> iface) protected DataSourceObtain the targetDataSourcefor actual use (nevernull).voidsetLoginTimeout(int seconds) voidsetLogWriter(PrintWriter out) voidsetTargetDataSource(@Nullable DataSource targetDataSource) Set the target DataSource that this DataSource should delegate to.<T> T
-
Constructor Details
-
DelegatingDataSource
public DelegatingDataSource()Create a new DelegatingDataSource.- See Also:
-
DelegatingDataSource
Create a new DelegatingDataSource.- Parameters:
targetDataSource- the target DataSource
-
-
Method Details
-
setTargetDataSource
Set the target DataSource that this DataSource should delegate to. -
getTargetDataSource
Return the target DataSource that this DataSource should delegate to. -
obtainTargetDataSource
Obtain the targetDataSourcefor actual use (nevernull).- Since:
- 5.0
-
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface: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.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
createConnectionBuilder
- Specified by:
createConnectionBuilderin interfaceDataSource- Throws:
SQLException
-
createShardingKeyBuilder
- Specified by:
createShardingKeyBuilderin interfaceCommonDataSource- Throws:
SQLException
-
getLoginTimeout
- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
setLoginTimeout
- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
getLogWriter
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Throws:
SQLException
-
setLogWriter
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-