Package org.apache.tomcat.dbcp.dbcp2
Class DelegatingPreparedStatement
- java.lang.Object
-
- org.apache.tomcat.dbcp.dbcp2.AbandonedTrace
-
- org.apache.tomcat.dbcp.dbcp2.DelegatingStatement
-
- org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement
-
- All Implemented Interfaces:
AutoCloseable,PreparedStatement,Statement,Wrapper,TrackedUse
- Direct Known Subclasses:
DelegatingCallableStatement,PoolablePreparedStatement
public class DelegatingPreparedStatement extends DelegatingStatement implements PreparedStatement
A base delegating implementation ofPreparedStatement.All of the methods from the
PreparedStatementinterface simply check to see that thePreparedStatementis 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
Constructors Constructor Description DelegatingPreparedStatement(DelegatingConnection<?> connection, PreparedStatement 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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddBatch()voidclearParameters()booleanexecute()longexecuteLargeUpdate()ResultSetexecuteQuery()intexecuteUpdate()ResultSetMetaDatagetMetaData()ParameterMetaDatagetParameterMetaData()voidsetArray(int i, Array x)voidsetAsciiStream(int parameterIndex, InputStream inputStream)voidsetAsciiStream(int parameterIndex, InputStream x, int length)voidsetAsciiStream(int parameterIndex, InputStream inputStream, long length)voidsetBigDecimal(int parameterIndex, BigDecimal x)voidsetBinaryStream(int parameterIndex, InputStream inputStream)voidsetBinaryStream(int parameterIndex, InputStream x, int length)voidsetBinaryStream(int parameterIndex, InputStream inputStream, long length)voidsetBlob(int parameterIndex, InputStream inputStream)voidsetBlob(int parameterIndex, InputStream inputStream, long length)voidsetBlob(int i, Blob x)voidsetBoolean(int parameterIndex, boolean x)voidsetByte(int parameterIndex, byte x)voidsetBytes(int parameterIndex, byte[] x)voidsetCharacterStream(int parameterIndex, Reader reader)voidsetCharacterStream(int parameterIndex, Reader reader, int length)voidsetCharacterStream(int parameterIndex, Reader reader, long length)voidsetClob(int parameterIndex, Reader reader)voidsetClob(int parameterIndex, Reader reader, long length)voidsetClob(int i, Clob x)voidsetDate(int parameterIndex, Date x)voidsetDate(int parameterIndex, Date x, Calendar cal)voidsetDouble(int parameterIndex, double x)voidsetFloat(int parameterIndex, float x)voidsetInt(int parameterIndex, int x)voidsetLong(int parameterIndex, long x)voidsetNCharacterStream(int parameterIndex, Reader reader)voidsetNCharacterStream(int parameterIndex, Reader value, long length)voidsetNClob(int parameterIndex, Reader reader)voidsetNClob(int parameterIndex, Reader reader, long length)voidsetNClob(int parameterIndex, NClob value)voidsetNString(int parameterIndex, String value)voidsetNull(int parameterIndex, int sqlType)voidsetNull(int paramIndex, int sqlType, String typeName)voidsetObject(int parameterIndex, Object x)voidsetObject(int parameterIndex, Object x, int targetSqlType)voidsetObject(int parameterIndex, Object x, int targetSqlType, int scale)voidsetObject(int parameterIndex, Object x, SQLType targetSqlType)voidsetObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)voidsetRef(int i, Ref x)voidsetRowId(int parameterIndex, RowId value)voidsetShort(int parameterIndex, short x)voidsetSQLXML(int parameterIndex, SQLXML value)voidsetString(int parameterIndex, String x)voidsetTime(int parameterIndex, Time x)voidsetTime(int parameterIndex, Time x, Calendar cal)voidsetTimestamp(int parameterIndex, Timestamp x)voidsetTimestamp(int parameterIndex, Timestamp x, Calendar cal)voidsetUnicodeStream(int parameterIndex, InputStream x, int length)Deprecated.Use setAsciiStream(), setCharacterStream() or setNCharacterStream()voidsetURL(int parameterIndex, URL x)StringtoString()Returns a String representation of this object.-
Methods inherited from class org.apache.tomcat.dbcp.dbcp2.DelegatingStatement
activate, addBatch, cancel, checkOpen, clearBatch, clearWarnings, close, closeOnCompletion, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, finalize, getConnection, getConnectionInternal, getDelegate, getFetchDirection, getFetchSize, getGeneratedKeys, getInnermostDelegate, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, handleException, isClosed, isClosedInternal, isCloseOnCompletion, isPoolable, isWrapperFor, passivate, setClosedInternal, setCursorName, setDelegate, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrap
-
Methods inherited from class org.apache.tomcat.dbcp.dbcp2.AbandonedTrace
addTrace, clearTrace, getLastUsed, getLastUsedInstant, getTrace, removeThisTrace, removeTrace, setLastUsed, setLastUsed, setLastUsed
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Constructor Detail
-
DelegatingPreparedStatement
public DelegatingPreparedStatement(DelegatingConnection<?> connection, PreparedStatement statement)
Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it.- Parameters:
statement- thePreparedStatementto delegate all calls to.connection- theDelegatingConnectionthat created this statement.
-
-
Method Detail
-
addBatch
public void addBatch() throws SQLException- Specified by:
addBatchin interfacePreparedStatement- Throws:
SQLException
-
clearParameters
public void clearParameters() throws SQLException- Specified by:
clearParametersin interfacePreparedStatement- Throws:
SQLException
-
execute
public boolean execute() throws SQLException- Specified by:
executein interfacePreparedStatement- Throws:
SQLException
-
executeLargeUpdate
public long executeLargeUpdate() throws SQLException- Specified by:
executeLargeUpdatein interfacePreparedStatement- Throws:
SQLException- Since:
- 2.5.0
-
executeQuery
public ResultSet executeQuery() throws SQLException
- Specified by:
executeQueryin interfacePreparedStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate() throws SQLException- Specified by:
executeUpdatein interfacePreparedStatement- Throws:
SQLException
-
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
- Specified by:
getMetaDatain interfacePreparedStatement- Throws:
SQLException
-
getParameterMetaData
public ParameterMetaData getParameterMetaData() throws SQLException
- Specified by:
getParameterMetaDatain interfacePreparedStatement- Throws:
SQLException
-
setArray
public void setArray(int i, Array x) throws SQLException- Specified by:
setArrayin interfacePreparedStatement- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream inputStream) throws SQLException- Specified by:
setAsciiStreamin interfacePreparedStatement- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException- Specified by:
setAsciiStreamin interfacePreparedStatement- Throws:
SQLException
-
setAsciiStream
public void setAsciiStream(int parameterIndex, InputStream inputStream, long length) throws SQLException- Specified by:
setAsciiStreamin interfacePreparedStatement- Throws:
SQLException
-
setBigDecimal
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException- Specified by:
setBigDecimalin interfacePreparedStatement- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream inputStream) throws SQLException- Specified by:
setBinaryStreamin interfacePreparedStatement- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException- Specified by:
setBinaryStreamin interfacePreparedStatement- Throws:
SQLException
-
setBinaryStream
public void setBinaryStream(int parameterIndex, InputStream inputStream, long length) throws SQLException- Specified by:
setBinaryStreamin interfacePreparedStatement- Throws:
SQLException
-
setBlob
public void setBlob(int i, Blob x) throws SQLException- Specified by:
setBlobin interfacePreparedStatement- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException- Specified by:
setBlobin interfacePreparedStatement- Throws:
SQLException
-
setBlob
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException- Specified by:
setBlobin interfacePreparedStatement- Throws:
SQLException
-
setBoolean
public void setBoolean(int parameterIndex, boolean x) throws SQLException- Specified by:
setBooleanin interfacePreparedStatement- Throws:
SQLException
-
setByte
public void setByte(int parameterIndex, byte x) throws SQLException- Specified by:
setBytein interfacePreparedStatement- Throws:
SQLException
-
setBytes
public void setBytes(int parameterIndex, byte[] x) throws SQLException- Specified by:
setBytesin interfacePreparedStatement- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException- Specified by:
setCharacterStreamin interfacePreparedStatement- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException- Specified by:
setCharacterStreamin interfacePreparedStatement- Throws:
SQLException
-
setCharacterStream
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException- Specified by:
setCharacterStreamin interfacePreparedStatement- Throws:
SQLException
-
setClob
public void setClob(int i, Clob x) throws SQLException- Specified by:
setClobin interfacePreparedStatement- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader) throws SQLException- Specified by:
setClobin interfacePreparedStatement- Throws:
SQLException
-
setClob
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException- Specified by:
setClobin interfacePreparedStatement- Throws:
SQLException
-
setDate
public void setDate(int parameterIndex, Date x) throws SQLException- Specified by:
setDatein interfacePreparedStatement- Throws:
SQLException
-
setDate
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException- Specified by:
setDatein interfacePreparedStatement- Throws:
SQLException
-
setDouble
public void setDouble(int parameterIndex, double x) throws SQLException- Specified by:
setDoublein interfacePreparedStatement- Throws:
SQLException
-
setFloat
public void setFloat(int parameterIndex, float x) throws SQLException- Specified by:
setFloatin interfacePreparedStatement- Throws:
SQLException
-
setInt
public void setInt(int parameterIndex, int x) throws SQLException- Specified by:
setIntin interfacePreparedStatement- Throws:
SQLException
-
setLong
public void setLong(int parameterIndex, long x) throws SQLException- Specified by:
setLongin interfacePreparedStatement- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader reader) throws SQLException- Specified by:
setNCharacterStreamin interfacePreparedStatement- Throws:
SQLException
-
setNCharacterStream
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException- Specified by:
setNCharacterStreamin interfacePreparedStatement- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, NClob value) throws SQLException- Specified by:
setNClobin interfacePreparedStatement- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader) throws SQLException- Specified by:
setNClobin interfacePreparedStatement- Throws:
SQLException
-
setNClob
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException- Specified by:
setNClobin interfacePreparedStatement- Throws:
SQLException
-
setNString
public void setNString(int parameterIndex, String value) throws SQLException- Specified by:
setNStringin interfacePreparedStatement- Throws:
SQLException
-
setNull
public void setNull(int parameterIndex, int sqlType) throws SQLException- Specified by:
setNullin interfacePreparedStatement- Throws:
SQLException
-
setNull
public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException- Specified by:
setNullin interfacePreparedStatement- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object x) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException
-
setObject
public void setObject(int parameterIndex, Object x, SQLType targetSqlType) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException- Since:
- 2.5.0
-
setObject
public void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException- Specified by:
setObjectin interfacePreparedStatement- Throws:
SQLException- Since:
- 2.5.0
-
setRef
public void setRef(int i, Ref x) throws SQLException- Specified by:
setRefin interfacePreparedStatement- Throws:
SQLException
-
setRowId
public void setRowId(int parameterIndex, RowId value) throws SQLException- Specified by:
setRowIdin interfacePreparedStatement- Throws:
SQLException
-
setShort
public void setShort(int parameterIndex, short x) throws SQLException- Specified by:
setShortin interfacePreparedStatement- Throws:
SQLException
-
setSQLXML
public void setSQLXML(int parameterIndex, SQLXML value) throws SQLException- Specified by:
setSQLXMLin interfacePreparedStatement- Throws:
SQLException
-
setString
public void setString(int parameterIndex, String x) throws SQLException- Specified by:
setStringin interfacePreparedStatement- Throws:
SQLException
-
setTime
public void setTime(int parameterIndex, Time x) throws SQLException- Specified by:
setTimein interfacePreparedStatement- Throws:
SQLException
-
setTime
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException- Specified by:
setTimein interfacePreparedStatement- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException- Specified by:
setTimestampin interfacePreparedStatement- Throws:
SQLException
-
setTimestamp
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException- Specified by:
setTimestampin interfacePreparedStatement- Throws:
SQLException
-
setUnicodeStream
@Deprecated public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
Deprecated.Use setAsciiStream(), setCharacterStream() or setNCharacterStream()- Specified by:
setUnicodeStreamin interfacePreparedStatement- Throws:
SQLException
-
setURL
public void setURL(int parameterIndex, URL x) throws SQLException- Specified by:
setURLin interfacePreparedStatement- Throws:
SQLException
-
toString
public String toString()
Returns a String representation of this object.- Overrides:
toStringin classDelegatingStatement- Returns:
- String
-
-