Package | Class | Use | Tree | Deprecated | Index | Help
| log4jdbc4 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.log4jdbc
Class StatementSpy

    java.lang.Object
      net.sf.log4jdbc.StatementSpy

All Implemented Interfaces:
  Statement, Wrapper, Spy

Direct Known Subclasses:
  PreparedStatementSpy

    public class StatementSpy

extends Object
implements Statement, Spy

Wraps a Statement and reports method calls, returns and exceptions. jdbc 4.0 version

Author:
  Arthur Blake
See Also:
  `for the jdbc 3 version.`

Field Summary
`protected ConnectionSpy` | `connectionSpy` The Connection that created this Statement.
`protected List` | `currentBatch` Tracking of current batch (see addBatch, clearBatch and executeBatch) //todo: should access to this List be synchronized?
`protected Statement` | `realStatement` The real statement that this StatementSpy wraps.

Fields inherited from interface java.sql.Statement
`CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO`

Constructor Summary
`StatementSpy(ConnectionSpy connectionSpy, Statement realStatement)` Create a StatementSpy (JDBC 4.0 version) that wraps another Statement, for the purpose of logging all method calls, sql, exceptions and return values.

Method Summary
`void` | `addBatch(String sql)`
`void` | `cancel()`
`void` | `clearBatch()`
`void` | `clearWarnings()`
`void` | `close()`
`boolean` | `execute(String sql)`
`boolean` | `execute(String sql, int autoGeneratedKeys)`
`boolean` | `execute(String sql, int[] columnIndexes)`
`boolean` | `execute(String sql, String[] columnNames)`
`int[]` | `executeBatch()`
`ResultSet` | `executeQuery(String sql)`
`int` | `executeUpdate(String sql)`
`int` | `executeUpdate(String sql, int autoGeneratedKeys)`
`int` | `executeUpdate(String sql, int[] columnIndexes)`
`int` | `executeUpdate(String sql, String[] columnNames)`
`String` | `getClassType()` Get the type of class being spied upon.
`Connection` | `getConnection()`
`int` | `getConnectionNumber()` Get the connection number.
`int` | `getFetchDirection()`
`int` | `getFetchSize()`
`ResultSet` | `getGeneratedKeys()`
`int` | `getMaxFieldSize()`
`int` | `getMaxRows()`
`boolean` | `getMoreResults()`
`boolean` | `getMoreResults(int current)`
`int` | `getQueryTimeout()`
`ResultSet` | `getResultSet()`
`int` | `getResultSetConcurrency()`
`int` | `getResultSetHoldability()`
`int` | `getResultSetType()`
`int` | `getUpdateCount()`
`SQLWarning` | `getWarnings()`
`boolean` | `isClosed()`
`boolean` | `isPoolable()`
`boolean` | `isWrapperFor(Class<?> iface)`
`protected void` | `reportAllReturns(String methodCall, String msg)` Report (for logging) that a method returned.
`protected void` | `reportException(String methodCall, SQLException exception)` Report an exception to be logged.
`protected void` | `reportException(String methodCall, SQLException exception, String sql)` Report an exception to be logged.
`protected void` | `reportException(String methodCall, SQLException exception, String sql, long execTime)` Report an exception to be logged which includes timing data on a sql failure.
`protected void` | `reportReturn(String methodCall)` Conveniance method to report (for logging) that a method returned (void return type).
`protected boolean` | `reportReturn(String methodCall, boolean value)` Conveniance method to report (for logging) that a method returned a boolean value.
`protected byte` | `reportReturn(String methodCall, byte value)` Conveniance method to report (for logging) that a method returned a byte value.
`protected double` | `reportReturn(String methodCall, double value)` Conveniance method to report (for logging) that a method returned a double value.
`protected float` | `reportReturn(String methodCall, float value)` Conveniance method to report (for logging) that a method returned a float value.
`protected int` | `reportReturn(String methodCall, int value)` Conveniance method to report (for logging) that a method returned a int value.
`protected long` | `reportReturn(String methodCall, long value)` Conveniance method to report (for logging) that a method returned a long value.
`protected Object` | `reportReturn(String methodCall, Object value)` Conveniance method to report (for logging) that a method returned an Object.
`protected short` | `reportReturn(String methodCall, short value)` Conveniance method to report (for logging) that a method returned a short value.
`protected void` | `reportSql(String sql, String methodCall)` Report SQL for logging.
`protected void` | `reportSqlTiming(long execTime, String sql, String methodCall)` Report SQL for logging.
`protected void` | `reportStatementSql(String sql, String methodCall)` Report SQL for logging with a warning that it was generated from a statement.
`protected void` | `reportStatementSqlTiming(long execTime, String sql, String methodCall)` Report SQL for logging with a warning that it was generated from a statement.
`void` | `setCursorName(String name)`
`void` | `setEscapeProcessing(boolean enable)`
`void` | `setFetchDirection(int direction)`
`void` | `setFetchSize(int rows)`
`void` | `setMaxFieldSize(int max)`
`void` | `setMaxRows(int max)`
`void` | `setPoolable(boolean poolable)`
`void` | `setQueryTimeout(int seconds)`
`
`<T> T`
` | `unwrap(Class<T> iface)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### connectionSpy

    protected ConnectionSpy connectionSpy

  The Connection that created this Statement.

### realStatement

    protected Statement realStatement

  The real statement that this StatementSpy wraps.

### currentBatch

    protected List currentBatch

  Tracking of current batch (see addBatch, clearBatch and executeBatch) //todo: should access to this List be synchronized?

Constructor Detail

### StatementSpy

    public StatementSpy(ConnectionSpy connectionSpy,
                        Statement realStatement)

  Create a StatementSpy (JDBC 4.0 version) that wraps another Statement, for the purpose of logging all method calls, sql, exceptions and return values.

  Parameters:
    `connectionSpy` - Connection that created this Statement.
    `realStatement` - real underlying Statement that this StatementSpy wraps.

Method Detail

### getClassType

    public String getClassType()

  Description copied from interface: `Spy`
  Get the type of class being spied upon. For example, "Statement", "ResultSet", etc.

  Specified by:
    `getClassType` in interface `Spy`
  Returns:
    a description of the type of class being spied upon.

### getConnectionNumber

    public int getConnectionNumber()

  Description copied from interface: `Spy`
  Get the connection number. In general, this is used to track which underlying connection is being used from the database. The number will be incremented each time a new Connection is retrieved from the real underlying jdbc driver. This is useful for debugging and tracking down problems with connection pooling.

  Specified by:
    `getConnectionNumber` in interface `Spy`
  Returns:
    the connection instance number.

### reportException

    protected void reportException(String methodCall,
                                   SQLException exception,
                                   String sql,
                                   long execTime)

  Report an exception to be logged which includes timing data on a sql failure.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that generated the exception.
    `exception` - exception that was generated
    `sql` - SQL associated with the call.
    `execTime` - amount of time that the jdbc driver was chugging on the SQL before it threw an exception.

### reportException

    protected void reportException(String methodCall,
                                   SQLException exception,
                                   String sql)

  Report an exception to be logged.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that generated the exception.
    `exception` - exception that was generated
    `sql` - SQL associated with the call.

### reportException

    protected void reportException(String methodCall,
                                   SQLException exception)

  Report an exception to be logged.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that generated the exception.
    `exception` - exception that was generated

### reportAllReturns

    protected void reportAllReturns(String methodCall,
                                    String msg)

  Report (for logging) that a method returned. All the other reportReturn methods are conveniance methods that call this method.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `msg` - description of what the return value that was returned. may be an empty String for void return types.

### reportReturn

    protected boolean reportReturn(String methodCall,
                                   boolean value)

  Conveniance method to report (for logging) that a method returned a boolean value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - boolean return value.
  Returns:
    the boolean return value as passed in.

### reportReturn

    protected byte reportReturn(String methodCall,
                                byte value)

  Conveniance method to report (for logging) that a method returned a byte value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - byte return value.
  Returns:
    the byte return value as passed in.

### reportReturn

    protected int reportReturn(String methodCall,
                               int value)

  Conveniance method to report (for logging) that a method returned a int value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - int return value.
  Returns:
    the int return value as passed in.

### reportReturn

    protected double reportReturn(String methodCall,
                                  double value)

  Conveniance method to report (for logging) that a method returned a double value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - double return value.
  Returns:
    the double return value as passed in.

### reportReturn

    protected short reportReturn(String methodCall,
                                 short value)

  Conveniance method to report (for logging) that a method returned a short value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - short return value.
  Returns:
    the short return value as passed in.

### reportReturn

    protected long reportReturn(String methodCall,
                                long value)

  Conveniance method to report (for logging) that a method returned a long value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - long return value.
  Returns:
    the long return value as passed in.

### reportReturn

    protected float reportReturn(String methodCall,
                                 float value)

  Conveniance method to report (for logging) that a method returned a float value.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - float return value.
  Returns:
    the float return value as passed in.

### reportReturn

    protected Object reportReturn(String methodCall,
                                  Object value)

  Conveniance method to report (for logging) that a method returned an Object.

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.
    `value` - return Object.
  Returns:
    the return Object as passed in.

### reportReturn

    protected void reportReturn(String methodCall)

  Conveniance method to report (for logging) that a method returned (void return type).

  Parameters:
    `methodCall` - description of method call and arguments passed to it that returned.

### reportStatementSql

    protected void reportStatementSql(String sql,
                                      String methodCall)

  Report SQL for logging with a warning that it was generated from a statement.

  Parameters:
    `sql` - the SQL being run
    `methodCall` - the name of the method that was running the SQL

### reportStatementSqlTiming

    protected void reportStatementSqlTiming(long execTime,
                                            String sql,
                                            String methodCall)

  Report SQL for logging with a warning that it was generated from a statement.

  Parameters:
    `execTime` - execution time in msec.
    `sql` - the SQL being run
    `methodCall` - the name of the method that was running the SQL

### reportSqlTiming

    protected void reportSqlTiming(long execTime,
                                   String sql,
                                   String methodCall)

  Report SQL for logging.

  Parameters:
    `execTime` - execution time in msec.
    `sql` - the SQL being run
    `methodCall` - the name of the method that was running the SQL

### reportSql

    protected void reportSql(String sql,
                             String methodCall)

  Report SQL for logging.

  Parameters:
    `sql` - the SQL being run
    `methodCall` - the name of the method that was running the SQL

### getWarnings

    public SQLWarning getWarnings()
                           throws SQLException

  Specified by:
    `getWarnings` in interface `Statement`
  Throws:
    `SQLException`

### executeUpdate

    public int executeUpdate(String sql,
                             String[] columnNames)
                      throws SQLException

  Specified by:
    `executeUpdate` in interface `Statement`
  Throws:
    `SQLException`

### execute

    public boolean execute(String sql,
                           String[] columnNames)
                    throws SQLException

  Specified by:
    `execute` in interface `Statement`
  Throws:
    `SQLException`

### setMaxRows

    public void setMaxRows(int max)
                    throws SQLException

  Specified by:
    `setMaxRows` in interface `Statement`
  Throws:
    `SQLException`

### getMoreResults

    public boolean getMoreResults()
                           throws SQLException

  Specified by:
    `getMoreResults` in interface `Statement`
  Throws:
    `SQLException`

### clearWarnings

    public void clearWarnings()
                       throws SQLException

  Specified by:
    `clearWarnings` in interface `Statement`
  Throws:
    `SQLException`

### addBatch

    public void addBatch(String sql)
                  throws SQLException

  Specified by:
    `addBatch` in interface `Statement`
  Throws:
    `SQLException`

### getResultSetType

    public int getResultSetType()
                         throws SQLException

  Specified by:
    `getResultSetType` in interface `Statement`
  Throws:
    `SQLException`

### clearBatch

    public void clearBatch()
                    throws SQLException

  Specified by:
    `clearBatch` in interface `Statement`
  Throws:
    `SQLException`

### setFetchDirection

    public void setFetchDirection(int direction)
                           throws SQLException

  Specified by:
    `setFetchDirection` in interface `Statement`
  Throws:
    `SQLException`

### executeBatch

    public int[] executeBatch()
                       throws SQLException

  Specified by:
    `executeBatch` in interface `Statement`
  Throws:
    `SQLException`

### setFetchSize

    public void setFetchSize(int rows)
                      throws SQLException

  Specified by:
    `setFetchSize` in interface `Statement`
  Throws:
    `SQLException`

### getQueryTimeout

    public int getQueryTimeout()
                        throws SQLException

  Specified by:
    `getQueryTimeout` in interface `Statement`
  Throws:
    `SQLException`

### getConnection

    public Connection getConnection()
                             throws SQLException

  Specified by:
    `getConnection` in interface `Statement`
  Throws:
    `SQLException`

### getGeneratedKeys

    public ResultSet getGeneratedKeys()
                               throws SQLException

  Specified by:
    `getGeneratedKeys` in interface `Statement`
  Throws:
    `SQLException`

### setEscapeProcessing

    public void setEscapeProcessing(boolean enable)
                             throws SQLException

  Specified by:
    `setEscapeProcessing` in interface `Statement`
  Throws:
    `SQLException`

### getFetchDirection

    public int getFetchDirection()
                          throws SQLException

  Specified by:
    `getFetchDirection` in interface `Statement`
  Throws:
    `SQLException`

### setQueryTimeout

    public void setQueryTimeout(int seconds)
                         throws SQLException

  Specified by:
    `setQueryTimeout` in interface `Statement`
  Throws:
    `SQLException`

### getMoreResults

    public boolean getMoreResults(int current)
                           throws SQLException

  Specified by:
    `getMoreResults` in interface `Statement`
  Throws:
    `SQLException`

### executeQuery

    public ResultSet executeQuery(String sql)
                           throws SQLException

  Specified by:
    `executeQuery` in interface `Statement`
  Throws:
    `SQLException`

### getMaxFieldSize

    public int getMaxFieldSize()
                        throws SQLException

  Specified by:
    `getMaxFieldSize` in interface `Statement`
  Throws:
    `SQLException`

### executeUpdate

    public int executeUpdate(String sql)
                      throws SQLException

  Specified by:
    `executeUpdate` in interface `Statement`
  Throws:
    `SQLException`

### cancel

    public void cancel()
                throws SQLException

  Specified by:
    `cancel` in interface `Statement`
  Throws:
    `SQLException`

### setCursorName

    public void setCursorName(String name)
                       throws SQLException

  Specified by:
    `setCursorName` in interface `Statement`
  Throws:
    `SQLException`

### getFetchSize

    public int getFetchSize()
                     throws SQLException

  Specified by:
    `getFetchSize` in interface `Statement`
  Throws:
    `SQLException`

### getResultSetConcurrency

    public int getResultSetConcurrency()
                                throws SQLException

  Specified by:
    `getResultSetConcurrency` in interface `Statement`
  Throws:
    `SQLException`

### getResultSetHoldability

    public int getResultSetHoldability()
                                throws SQLException

  Specified by:
    `getResultSetHoldability` in interface `Statement`
  Throws:
    `SQLException`

### isClosed

    public boolean isClosed()
                     throws SQLException

  Specified by:
    `isClosed` in interface `Statement`
  Throws:
    `SQLException`

### setPoolable

    public void setPoolable(boolean poolable)
                     throws SQLException

  Specified by:
    `setPoolable` in interface `Statement`
  Throws:
    `SQLException`

### isPoolable

    public boolean isPoolable()
                       throws SQLException

  Specified by:
    `isPoolable` in interface `Statement`
  Throws:
    `SQLException`

### setMaxFieldSize

    public void setMaxFieldSize(int max)
                         throws SQLException

  Specified by:
    `setMaxFieldSize` in interface `Statement`
  Throws:
    `SQLException`

### execute

    public boolean execute(String sql)
                    throws SQLException

  Specified by:
    `execute` in interface `Statement`
  Throws:
    `SQLException`

### executeUpdate

    public int executeUpdate(String sql,
                             int autoGeneratedKeys)
                      throws SQLException

  Specified by:
    `executeUpdate` in interface `Statement`
  Throws:
    `SQLException`

### execute

    public boolean execute(String sql,
                           int autoGeneratedKeys)
                    throws SQLException

  Specified by:
    `execute` in interface `Statement`
  Throws:
    `SQLException`

### executeUpdate

    public int executeUpdate(String sql,
                             int[] columnIndexes)
                      throws SQLException

  Specified by:
    `executeUpdate` in interface `Statement`
  Throws:
    `SQLException`

### execute

    public boolean execute(String sql,
                           int[] columnIndexes)
                    throws SQLException

  Specified by:
    `execute` in interface `Statement`
  Throws:
    `SQLException`

### getResultSet

    public ResultSet getResultSet()
                           throws SQLException

  Specified by:
    `getResultSet` in interface `Statement`
  Throws:
    `SQLException`

### getMaxRows

    public int getMaxRows()
                   throws SQLException

  Specified by:
    `getMaxRows` in interface `Statement`
  Throws:
    `SQLException`

### close

    public void close()
               throws SQLException

  Specified by:
    `close` in interface `Statement`
  Throws:
    `SQLException`

### getUpdateCount

    public int getUpdateCount()
                       throws SQLException

  Specified by:
    `getUpdateCount` in interface `Statement`
  Throws:
    `SQLException`

### unwrap

    public <T> T unwrap(Class<T> iface)
             throws SQLException

  Specified by:
    `unwrap` in interface `Wrapper`
  Throws:
    `SQLException`

### isWrapperFor

    public boolean isWrapperFor(Class<?> iface)
                         throws SQLException

  Specified by:
    `isWrapperFor` in interface `Wrapper`
  Throws:
    `SQLException`

Package | Class | Use | Tree | Deprecated | Index | Help
| log4jdbc4 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD