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.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_conprovider
private ConnectionProvider _conprovider
_loglistener
private LogListener _loglistener
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);
// ...
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