safejdbc
Class LoggingWrapper

java.lang.Object
  |
  +--safejdbc.LoggingWrapper
All Implemented Interfaces:
ConnectionProvider

public class LoggingWrapper
extends java.lang.Object
implements ConnectionProvider

If you want to log your SQL-Statements you just have to wrap your ConnectionProvider with a LoggingWrapper.


Constructor Summary
LoggingWrapper(ConnectionProvider conprovider)
          This constructor is for your convenience.
LoggingWrapper(ConnectionProvider conprovider, LogListener loglistener)
          Every SQL-Statement will be handed over to the LogListener.
 
Method Summary
 java.sql.Connection getConnection()
          This method is called to actually give the connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingWrapper

public LoggingWrapper(ConnectionProvider conprovider)
This constructor is for your convenience. All SQL-Statements are logged to System.out. What this constructor does inside is the following:
 this(conprovider,
      new LogListener() {
          public void log(String sqlstmt) {
              System.out.println(sqlstmt);
          }
      });
 

LoggingWrapper

public LoggingWrapper(ConnectionProvider conprovider,
                      LogListener loglistener)
Every SQL-Statement will be handed over to the LogListener. Assuming you want to integrate your own Logging-Service you could do the following:
 LogListener loglistener = new LogListener() {
     public void log(String sqlstmt) {
         MyLogger.log(sqlstmt);
     }
 };
 ConnectionProvider conprovider = new DataSourceAdapter(myDataSource);
 ConnectionProvider loggingconprovider = new LoggingWrapper(conprovider, loglistener);
 SQL sql = new SQLExecuter(loggingconprovider);
 // ... 
 
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Description copied from interface: ConnectionProvider
This method is called to actually give the connection
Specified by:
getConnection in interface ConnectionProvider


Copyright (c) 2001, 2002 by Jan Hermanns and Arno Haase. All Rights Reserved.