nl.knowledgeplaza.util.jdbc
Class Connection

java.lang.Object
  extended by nl.knowledgeplaza.util.jdbc.Connection
All Implemented Interfaces:
InvocationHandler

public class Connection
extends Object
implements 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 String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Method Summary
 void closeClosableObject(Object o)
           
static String createSqlTrace()
           
 String formatCall(String prefix, Method method, Object[] args)
           
 String formatCall(String prefix, Method method, Object[] args, Object retval)
           
 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()
           
 String getMyPrefix()
           
 String getPrefix()
           
 Object invoke(Object proxy, Method method, 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(String value)
           
 void traceClosableObject(Object o)
           
static Connection wrap(Connection connection)
           
static Connection wrap(Connection connection, String prefix)
           
static Connection wrap(Connection connection, 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
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Method Detail

getConnection

public Connection getConnection()
returns the original object for handling driver specific functions


wrap

public static Connection wrap(Connection connection)
Parameters:
connection -
Returns:

wrap

public static Connection wrap(Connection connection,
                              String prefix)
Parameters:
connection -
Returns:

wrap

public static Connection wrap(Connection connection,
                              String prefix,
                              org.apache.log4j.Logger log4j)

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

setPrefix

public void setPrefix(String value)

getPrefix

public String getPrefix()

getMyPrefix

public 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 String createSqlTrace()

setLog4jResultset

public void setLog4jResultset(org.apache.log4j.Logger value)

getLog4jResultset

public org.apache.log4j.Logger getLog4jResultset()

formatCall

public String formatCall(String prefix,
                         Method method,
                         Object[] args)
Parameters:
method -
args -
Returns:

formatCall

public String formatCall(String prefix,
                         Method method,
                         Object[] args,
                         Object retval)
Parameters:
method -
args -
retval -
Returns:

traceClosableObject

public void traceClosableObject(Object o)

closeClosableObject

public void closeClosableObject(Object o)

reportCloseStatus

public void reportCloseStatus()


Copyright © 2012 KnowledgePlaza. All Rights Reserved.