org.apache.commons.dbcp

Class DelegatingStatement

Implemented Interfaces:
Statement
Known Direct Subclasses:
DelegatingPreparedStatement

public class DelegatingStatement
extends AbandonedTrace
implements Statement

A base delegating implementation of Statement.

All of the methods from the Statement interface simply check to see that the Statement is active, and call the corresponding method on the "delegate" provided in my constructor.

Extends AbandonedTrace to implement Statement tracking and logging of code which created the Statement. Tracking the Statement ensures that the Connection which created it can close any open Statement's on Connection close.

Version:
$Revision: 1.17 $ $Date: 2004/03/06 13:35:31 $

Authors:
Rodney Waldhoff
Glenn L. Nielsen
James House
Dirk Verbeeck

Constructor Summary

DelegatingStatement(DelegatingConnection c, Statement s)
Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it.

Method Summary

void
addBatch(String sql)
void
cancel()
void
clearBatch()
void
clearWarnings()
void
close()
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.
boolean
equals(Object obj)
boolean
execute(String sql)
boolean
execute(String sql, columnIndexes[] )
boolean
execute(String sql, columnNames[] )
boolean
execute(String sql, int autoGeneratedKeys)
int[]
executeBatch()
ResultSet
executeQuery(String sql)
int
executeUpdate(String sql)
int
executeUpdate(String sql, columnIndexes[] )
int
executeUpdate(String sql, columnNames[] )
int
executeUpdate(String sql, int autoGeneratedKeys)
Connection
getConnection()
Statement
getDelegate()
Returns my underlying Statement.
int
getFetchDirection()
int
getFetchSize()
ResultSet
getGeneratedKeys()
Statement
getInnermostDelegate()
If my underlying Statement is not a DelegatingStatement, returns it, otherwise recursively invokes this method on my delegate.
int
getMaxFieldSize()
int
getMaxRows()
boolean
getMoreResults()
boolean
getMoreResults(int current)
int
getQueryTimeout()
ResultSet
getResultSet()
int
getResultSetConcurrency()
int
getResultSetHoldability()
int
getResultSetType()
int
getUpdateCount()
SQLWarning
getWarnings()
int
hashCode()
void
setCursorName(String name)
void
setDelegate(Statement s)
Sets my delegate.
void
setEscapeProcessing(boolean enable)
void
setFetchDirection(int direction)
void
setFetchSize(int rows)
void
setMaxFieldSize(int max)
void
setMaxRows(int max)
void
setQueryTimeout(int seconds)

Methods inherited from class org.apache.commons.dbcp.AbandonedTrace

printStackTrace

Constructor Details

DelegatingStatement

public DelegatingStatement(DelegatingConnection c,
                           Statement s)
Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it.

Parameters:
c - the DelegatingConnection that created this statement.
s - the Statement to delegate all calls to.

Method Details

addBatch

public void addBatch(String sql)
            throws SQLException


cancel

public void cancel()
            throws SQLException


clearBatch

public void clearBatch()
            throws SQLException


clearWarnings

public void clearWarnings()
            throws SQLException


close

public void close()
            throws SQLException
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.


equals

public boolean equals(Object obj)


execute

public boolean execute(String sql)
            throws SQLException


execute

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


execute

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


execute

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


executeBatch

public int[] executeBatch()
            throws SQLException


executeQuery

public ResultSet executeQuery(String sql)
            throws SQLException


executeUpdate

public int executeUpdate(String sql)
            throws SQLException


executeUpdate

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


executeUpdate

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


executeUpdate

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


getConnection

public Connection getConnection()
            throws SQLException


getDelegate

public Statement getDelegate()
Returns my underlying Statement.

Returns:
my underlying Statement.

See Also:
getInnermostDelegate()


getFetchDirection

public int getFetchDirection()
            throws SQLException


getFetchSize

public int getFetchSize()
            throws SQLException


getGeneratedKeys

public ResultSet getGeneratedKeys()
            throws SQLException


getInnermostDelegate

public Statement getInnermostDelegate()
If my underlying Statement is not a DelegatingStatement, returns it, otherwise recursively invokes this method on my delegate.

Hence this method will return the first delegate that is not a DelegatingStatement or null when no non-DelegatingStatement delegate can be found by transversing this chain.

This method is useful when you may have nested DelegatingStatements, and you want to make sure to obtain a "genuine" Statement.

See Also:
getDelegate()


getMaxFieldSize

public int getMaxFieldSize()
            throws SQLException


getMaxRows

public int getMaxRows()
            throws SQLException


getMoreResults

public boolean getMoreResults()
            throws SQLException


getMoreResults

public boolean getMoreResults(int current)
            throws SQLException


getQueryTimeout

public int getQueryTimeout()
            throws SQLException


getResultSet

public ResultSet getResultSet()
            throws SQLException


getResultSetConcurrency

public int getResultSetConcurrency()
            throws SQLException


getResultSetHoldability

public int getResultSetHoldability()
            throws SQLException


getResultSetType

public int getResultSetType()
            throws SQLException


getUpdateCount

public int getUpdateCount()
            throws SQLException


getWarnings

public SQLWarning getWarnings()
            throws SQLException


hashCode

public int hashCode()


setCursorName

public void setCursorName(String name)
            throws SQLException


setDelegate

public void setDelegate(Statement s)
Sets my delegate.


setEscapeProcessing

public void setEscapeProcessing(boolean enable)
            throws SQLException


setFetchDirection

public void setFetchDirection(int direction)
            throws SQLException


setFetchSize

public void setFetchSize(int rows)
            throws SQLException


setMaxFieldSize

public void setMaxFieldSize(int max)
            throws SQLException


setMaxRows

public void setMaxRows(int max)
            throws SQLException


setQueryTimeout

public void setQueryTimeout(int seconds)
            throws SQLException


Copyright © 2001-2003 Apache Software Foundation. Documenation generated May 22 2005.