Class DataSourceWrapper
- java.lang.Object
-
- de.aristaflow.adept2.base.registry.dbconfiguration.DataSourceWrapper
-
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
public class DataSourceWrapper extends Object implements DataSource
A simple wrapper for aJDBCDataSourcewhich is required byDatabaseConfiguration. Note that onlygetConnection()is implemented. All other methods throw anUnsupportedOperationException.
This implementation needs to be changed as soon asDatabaseConfigurationuses more thangetConnection().- Author:
- Ulrich Kreher
-
-
Field Summary
Fields Modifier and Type Field Description protected JDBCDataSourcedataSourceThe data source providing the connection.protected static StringunsupportedThe message for theUnsupportedOperationExceptions thrown by all methods exceptgetConnection().
-
Constructor Summary
Constructors Constructor Description DataSourceWrapper(JDBCDataSource dataSource)Creates aDataSourceproviding a connection from the designatedJDBCDataSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectiongetConnection()ConnectiongetConnection(String username, String password)intgetLoginTimeout()PrintWritergetLogWriter()LoggergetParentLogger()booleanisWrapperFor(Class<?> iface)voidsetLoginTimeout(int seconds)voidsetLogWriter(PrintWriter out)<T> Tunwrap(Class<T> iface)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
-
-
-
Field Detail
-
unsupported
protected static final String unsupported
The message for theUnsupportedOperationExceptions thrown by all methods exceptgetConnection().- See Also:
- Constant Field Values
-
dataSource
protected final JDBCDataSource dataSource
The data source providing the connection.
-
-
Constructor Detail
-
DataSourceWrapper
public DataSourceWrapper(JDBCDataSource dataSource)
Creates aDataSourceproviding a connection from the designatedJDBCDataSource.- Parameters:
dataSource- The data source providing the connection.
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
public Connection getConnection(String username, String password)
- Specified by:
getConnectionin interfaceDataSource
-
getLoginTimeout
public int getLoginTimeout()
- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource
-
getLogWriter
public PrintWriter getLogWriter()
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds)
- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource
-
setLogWriter
public void setLogWriter(PrintWriter out)
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
-