Package org.apache.tomcat.dbcp.dbcp2
Class DelegatingStatement
java.lang.Object
org.apache.tomcat.dbcp.dbcp2.AbandonedTrace
org.apache.tomcat.dbcp.dbcp2.DelegatingStatement
- All Implemented Interfaces:
AutoCloseable,Statement,Wrapper,TrackedUse
- 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.
- Since:
- 2.0
-
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
ConstructorsConstructorDescriptionDelegatingStatement(DelegatingConnection<?> connection, Statement statement) Create 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 TypeMethodDescriptionvoidactivate()voidvoidcancel()protected voidvoidvoidvoidclose()Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.voidbooleanbooleanbooleanbooleanint[]long[]longexecuteLargeUpdate(String sql) longexecuteLargeUpdate(String sql, int autoGeneratedKeys) longexecuteLargeUpdate(String sql, int[] columnIndexes) longexecuteLargeUpdate(String sql, String[] columnNames) executeQuery(String sql) intexecuteUpdate(String sql) intexecuteUpdate(String sql, int autoGeneratedKeys) intexecuteUpdate(String sql, int[] columnIndexes) intexecuteUpdate(String sql, String[] columnNames) protected voidfinalize()protected DelegatingConnection<?> Returns my underlyingStatement.intintIf my underlyingStatementis not aDelegatingStatement, returns it, otherwise recursively invokes this method on my delegate.longlongintintbooleanbooleangetMoreResults(int current) intintintintintprotected voidbooleanisClosed()protected booleanbooleanbooleanbooleanisWrapperFor(Class<?> iface) voidprotected voidsetClosedInternal(boolean closed) voidsetCursorName(String name) voidsetDelegate(Statement statement) Sets my delegate.voidsetEscapeProcessing(boolean enable) voidsetFetchDirection(int direction) voidsetFetchSize(int rows) voidsetLargeMaxRows(long max) voidsetMaxFieldSize(int max) voidsetMaxRows(int max) voidsetPoolable(boolean poolable) voidsetQueryTimeout(int seconds) toString()Returns a String representation of this object.<T> TMethods inherited from class org.apache.tomcat.dbcp.dbcp2.AbandonedTrace
addTrace, clearTrace, close, getLastUsed, getLastUsedInstant, getTrace, removeThisTrace, removeTrace, setLastUsed, setLastUsed, setLastUsedMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, isSimpleIdentifier
-
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:
connection- theDelegatingConnectionthat created this statement.statement- theStatementto delegate all calls to.
-
-
Method Details
-
activate
- Throws:
SQLException- thrown by the delegating statement.- Since:
- 2.4.0 made public, was protected in 2.3.0.
-
addBatch
- Specified by:
addBatchin interfaceStatement- Throws:
SQLException
-
cancel
- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
checkOpen
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException
-
close
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Overrides:
closein classAbandonedTrace- Throws:
SQLException- Ignored here, for subclasses.
-
closeOnCompletion
- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatchin interfaceStatement- Throws:
SQLException
-
executeLargeBatch
- Specified by:
executeLargeBatchin interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeQuery
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
finalize
-
getConnection
- Specified by:
getConnectionin interfaceStatement- Throws:
SQLException
-
getConnectionInternal
-
getDelegate
Returns my underlyingStatement.- Returns:
- my underlying
Statement. - See Also:
-
getFetchDirection
- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getGeneratedKeys
- Specified by:
getGeneratedKeysin interfaceStatement- Throws:
SQLException
-
getInnermostDelegate
If my underlyingStatementis not aDelegatingStatement, returns it, otherwise recursively invokes this method on my delegate.Hence this method will return the first delegate that is not a
DelegatingStatementornullwhen no non-DelegatingStatementdelegate can be found by traversing this chain.This method is useful when you may have nested
DelegatingStatements, and you want to make sure to obtain a "genuine"Statement.- Returns:
- The innermost delegate.
- See Also:
-
getLargeMaxRows
- Specified by:
getLargeMaxRowsin interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCountin interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
getMaxFieldSize
- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSetin interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
getResultSetHoldability
- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
getResultSetType
- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLException
-
getUpdateCount
- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLException
-
getWarnings
- Specified by:
getWarningsin interfaceStatement- Throws:
SQLException
-
handleException
- Throws:
SQLException
-
isClosed
- Specified by:
isClosedin interfaceStatement- Throws:
SQLException
-
isClosedInternal
protected boolean isClosedInternal() -
isCloseOnCompletion
- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
passivate
- Throws:
SQLException- thrown by the delegating statement.- Since:
- 2.4.0 made public, was protected in 2.3.0.
-
setClosedInternal
protected void setClosedInternal(boolean closed) -
setCursorName
- Specified by:
setCursorNamein interfaceStatement- Throws:
SQLException
-
setDelegate
Sets my delegate.- Parameters:
statement- my delegate.
-
setEscapeProcessing
- Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLException
-
setFetchDirection
- Specified by:
setFetchDirectionin interfaceStatement- Throws:
SQLException
-
setFetchSize
- Specified by:
setFetchSizein interfaceStatement- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRowsin interfaceStatement- Throws:
SQLException- Since:
- 2.5.0
-
setMaxFieldSize
- Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLException
-
setMaxRows
- Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLException
-
toString
Returns a String representation of this object. -
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-