public class DataSourceSpy extends Object implements DataSource, Spy
You can get log4jdbc to work on this using the following config changes
Constructor and Description |
---|
DataSourceSpy(DataSource realDataSource)
Constructor
|
Modifier and Type | Method and Description |
---|---|
String |
getClassType()
Get the type of class being spied upon.
|
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
Integer |
getConnectionNumber()
Get the connection number.
|
SpyLogDelegator |
getLogDelegator()
Get the
SpyLogDelegator that are used by all resources
obtained starting from this DataSource
(Connection s, ResultSet s, ...). |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
boolean |
isWrapperFor(Class<?> iface) |
protected void |
reportException(String methodCall,
SQLException exception)
Report to the logger all exceptions which have to be reported by this class
|
void |
setLogDelegator(SpyLogDelegator spyLogDelegator)
Set a custom
SpyLogDelegator to be used by all resources
provided by this DataSource , rather than the default
SpyLogDelegator returned by
SpyLogFactory#getSpyLogDelegator() . |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
<T> T |
unwrap(Class<T> iface) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParentLogger
public DataSourceSpy(DataSource realDataSource)
realDataSource
- the real DataSourcepublic SpyLogDelegator getLogDelegator()
SpyLogDelegator
that are used by all resources
obtained starting from this DataSource
(Connection
s, ResultSet
s, ...).SpyLogDelegator
currently used
by this DataSource
.public void setLogDelegator(SpyLogDelegator spyLogDelegator)
SpyLogDelegator
to be used by all resources
provided by this DataSource
, rather than the default
SpyLogDelegator
returned by
SpyLogFactory#getSpyLogDelegator()
.spyLogDelegator
- The SpyLogDelegator
to be used by all resources
obtained starting from this DataSource
(Connection
s, ResultSet
s, ...).protected void reportException(String methodCall, SQLException exception)
methodCall
- the method which threw an exceptionexception
- the thrown exceptionpublic Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public String getClassType()
Spy
getClassType
in interface Spy
public Integer getConnectionNumber()
Spy
getConnectionNumber
in interface Spy
Copyright © 2013 Bgee - Swiss Institute of Bioinformatics. All Rights Reserved.