public class DelegatingDataSource
extends java.lang.Object
implements javax.sql.DataSource
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(javax.sql.DataSource targetDataSource)
Create a new DelegatingDataSource.
|
| Modifier and Type | Method and Description |
|---|---|
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() |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
<T> T |
unwrap(java.lang.Class<T> iface) |
static javax.sql.DataSource |
unwrapDataSource(javax.sql.DataSource dataSource)
Unwraps the data source obtaining the target.
|
public DelegatingDataSource(@NonNull
javax.sql.DataSource targetDataSource)
targetDataSource - the target DataSource@NonNull public final javax.sql.DataSource getTargetDataSource()
public 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@NonNull
public static javax.sql.DataSource unwrapDataSource(@NonNull
javax.sql.DataSource dataSource)
dataSource - The data source