com.amazon.carbonado.repo.jdbc
Class LoggingDataSource

java.lang.Object
  extended by com.amazon.carbonado.repo.jdbc.LoggingDataSource
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource

public class LoggingDataSource
extends Object
implements DataSource

Wraps another DataSource such that all SQL statements are logged as debug.

Author:
Brian S O'Neill

Method Summary
 void close()
           
static DataSource create(DataSource ds)
          Wraps the given DataSource which logs to the default log.
static DataSource create(DataSource ds, org.apache.commons.logging.Log log)
          Wraps the given DataSource which logs to the given log.
 Connection getConnection()
           
 Connection getConnection(String username, String password)
           
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
 boolean isWrapperFor(Class<?> iface)
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(PrintWriter writer)
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static DataSource create(DataSource ds)
Wraps the given DataSource which logs to the default log. If debug logging is disabled, the original DataSource is returned.


create

public static DataSource create(DataSource ds,
                                org.apache.commons.logging.Log log)
Wraps the given DataSource which logs to the given log. If debug logging is disabled, the original DataSource is returned.


getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Specified by:
getLogWriter in interface CommonDataSource
Throws:
SQLException

setLogWriter

public void setLogWriter(PrintWriter writer)
                  throws SQLException
Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException
Specified by:
setLoginTimeout in interface CommonDataSource
Throws:
SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Specified by:
getLoginTimeout in interface CommonDataSource
Throws:
SQLException

close

public void close()
           throws SQLException
Throws:
SQLException
Since:
1.2

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Specified by:
unwrap in interface Wrapper
Throws:
SQLException
Since:
1.2

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Throws:
SQLException
Since:
1.2


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.