nl.knowledgeplaza.util.jdbc
Class Connection
java.lang.Object
nl.knowledgeplaza.util.jdbc.Connection
- All Implemented Interfaces:
- java.lang.reflect.InvocationHandler
public class Connection
- extends java.lang.Object
- implements java.lang.reflect.InvocationHandler
This is for logging SQL statements to log4j.
Use the wrap method to wrap a connection object and that is it.
There are several levels of logging
nl.knowledgeplaza.util.jdbc.Connection.sql - log all SQL related information, like create (prepared)statements, setting of parameters
nl.knowledgeplaza.util.jdbc.Connection.rest - less interesting calls, like close
nl.knowledgeplaza.util.jdbc.Connection.resultset - log the get actions against resultsets
xnl.knowledgeplaza.util.jdbc.Connection.sqltrace - log a stack trace so the origin of the call can be traced
- Version:
- $Revision: 1.4 $
|
Field Summary |
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
|
Method Summary |
void |
closeClosableObject(java.lang.Object o)
|
static java.lang.String |
createSqlTrace()
|
java.lang.String |
formatCall(java.lang.String prefix,
java.lang.reflect.Method method,
java.lang.Object[] args)
|
java.lang.String |
formatCall(java.lang.String prefix,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Object retval)
|
java.sql.Connection |
getConnection()
returns the original object for handling driver specific functions |
org.apache.log4j.Logger |
getLog4jRest()
|
org.apache.log4j.Logger |
getLog4jResultset()
|
org.apache.log4j.Logger |
getLog4jSql()
|
org.apache.log4j.Logger |
getLog4jSqlTrace()
|
java.lang.String |
getMyPrefix()
|
java.lang.String |
getPrefix()
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
|
void |
reportCloseStatus()
|
void |
setLog4jRest(org.apache.log4j.Logger value)
|
void |
setLog4jResultset(org.apache.log4j.Logger value)
|
void |
setLog4jSql(org.apache.log4j.Logger value)
|
void |
setLog4jSqlTrace(org.apache.log4j.Logger value)
|
void |
setPrefix(java.lang.String value)
|
void |
traceClosableObject(java.lang.Object o)
|
static java.sql.Connection |
wrap(java.sql.Connection connection)
|
static java.sql.Connection |
wrap(java.sql.Connection connection,
java.lang.String prefix)
|
static java.sql.Connection |
wrap(java.sql.Connection connection,
java.lang.String prefix,
org.apache.log4j.Logger log4j)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SOURCECODE_VERSION
public static final java.lang.String SOURCECODE_VERSION
- Standard variable for determining version of a class file.
- See Also:
- Constant Field Values
getConnection
public java.sql.Connection getConnection()
- returns the original object for handling driver specific functions
wrap
public static java.sql.Connection wrap(java.sql.Connection connection)
- Parameters:
connection -
- Returns:
wrap
public static java.sql.Connection wrap(java.sql.Connection connection,
java.lang.String prefix)
- Parameters:
connection -
- Returns:
wrap
public static java.sql.Connection wrap(java.sql.Connection connection,
java.lang.String prefix,
org.apache.log4j.Logger log4j)
invoke
public java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
- Specified by:
invoke in interface java.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable
setPrefix
public void setPrefix(java.lang.String value)
getPrefix
public java.lang.String getPrefix()
getMyPrefix
public java.lang.String getMyPrefix()
setLog4jRest
public void setLog4jRest(org.apache.log4j.Logger value)
getLog4jRest
public org.apache.log4j.Logger getLog4jRest()
setLog4jSql
public void setLog4jSql(org.apache.log4j.Logger value)
getLog4jSql
public org.apache.log4j.Logger getLog4jSql()
setLog4jSqlTrace
public void setLog4jSqlTrace(org.apache.log4j.Logger value)
getLog4jSqlTrace
public org.apache.log4j.Logger getLog4jSqlTrace()
createSqlTrace
public static java.lang.String createSqlTrace()
setLog4jResultset
public void setLog4jResultset(org.apache.log4j.Logger value)
getLog4jResultset
public org.apache.log4j.Logger getLog4jResultset()
formatCall
public java.lang.String formatCall(java.lang.String prefix,
java.lang.reflect.Method method,
java.lang.Object[] args)
- Parameters:
method - args -
- Returns:
formatCall
public java.lang.String formatCall(java.lang.String prefix,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Object retval)
- Parameters:
method - args - retval -
- Returns:
traceClosableObject
public void traceClosableObject(java.lang.Object o)
closeClosableObject
public void closeClosableObject(java.lang.Object o)
reportCloseStatus
public void reportCloseStatus()
Copyright © 2010. All Rights Reserved.