Package org.apache.commons.dbcp
Class DelegatingStatement
java.lang.Object
org.apache.commons.dbcp.AbandonedTrace
org.apache.commons.dbcp.DelegatingStatement
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
- Direct Known Subclasses:
DelegatingPreparedStatement
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: 896443 $ $Date: 2010-01-06 08:42:27 -0500 (Wed, 06 Jan 2010) $
- Author:
- Rodney Waldhoff, Glenn L. Nielsen, James House, Dirk Verbeeck
-
Field Summary
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
ConstructorsConstructorDescriptionCreate a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
cancel()
void
void
void
close()
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.void
boolean
This method considers two objects to be equal if the underlying jdbc objects are equal.boolean
boolean
boolean
boolean
int[]
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) Returns my underlyingStatement
.int
int
If my underlyingStatement
is not a DelegatingStatement, returns it, otherwise recursively invokes this method on my delegate.int
int
boolean
boolean
getMoreResults
(int current) int
int
int
int
int
int
hashCode()
boolean
isClosed()
boolean
boolean
boolean
isWrapperFor
(Class<?> iface) void
setCursorName
(String name) void
Sets my delegate.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) toString()
Returns a String representation of this object.<T> T
Methods inherited from class org.apache.commons.dbcp.AbandonedTrace
printStackTrace
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, getLargeUpdateCount, isSimpleIdentifier, setLargeMaxRows
-
Constructor Details
-
DelegatingStatement
Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it.- Parameters:
c
- theDelegatingConnection
that created this statement.s
- theStatement
to delegate all calls to.
-
-
Method Details
-
getDelegate
Returns my underlyingStatement
.- Returns:
- my underlying
Statement
. - See Also:
-
equals
This method considers two objects to be equal if the underlying jdbc objects are equal. -
hashCode
public int hashCode() -
getInnermostDelegate
If my underlyingStatement
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:
-
setDelegate
Sets my delegate. -
close
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
-
getConnection
- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
getMaxFieldSize
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
setMaxFieldSize
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
setMaxRows
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLException
-
setEscapeProcessing
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLException
-
getQueryTimeout
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
cancel
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
-
setCursorName
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
getUpdateCount
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
setFetchDirection
- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
setFetchSize
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLException
-
getResultSetType
- Specified by:
getResultSetType
in interfaceStatement
- Throws:
SQLException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
toString
Returns a String representation of this object. -
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getGeneratedKeys
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
getResultSetHoldability
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
isClosed
- Specified by:
isClosed
in interfaceStatement
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolable
in interfaceStatement
- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolable
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-