Class StasiPreparedStatement
java.lang.Object
clazzfish.jdbc.internal.StasiStatement
clazzfish.jdbc.internal.StasiPreparedStatement
- All Implemented Interfaces:
AutoCloseable,PreparedStatement,Statement,Wrapper
A simple wrapper for
PreparedStatement to be able to find resource
problems while reading and writing to the database. It allows us also to
measure times of SQL statements.
Why the name "Stasi..."? The Stasi was the official state security service of
Eastern Germany which controls the people (like NSA in the U.S. or KGB in
Russia, see also Wikipedia).
The StasiPreparedStatement controls the embedded PreparedStatement -
therefore the name.
- Author:
- oliver
-
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
ConstructorsConstructorDescriptionStasiPreparedStatement(PreparedStatement statement, Object... args) Instantiates a new stasi prepared statement. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds the batch.voidClear parameters.voidclose()Close the statement.booleanexecute()Execute.Execute query.intExecute update.Gets the meta data.Gets the parameter meta data.In some cicrumstances you may want to acces the originalPreparedStatementdirectly.voidSets the array.voidsetAsciiStream(int arg0, InputStream arg1) Sets the ascii stream.voidsetAsciiStream(int arg0, InputStream arg1, int arg2) Sets the ascii stream.voidsetAsciiStream(int arg0, InputStream arg1, long arg2) Sets the ascii stream.voidsetBigDecimal(int arg0, BigDecimal arg1) Sets the big decimal.voidsetBinaryStream(int arg0, InputStream arg1) Sets the binary stream.voidsetBinaryStream(int arg0, InputStream arg1, int arg2) Sets the binary stream.voidsetBinaryStream(int arg0, InputStream arg1, long arg2) Sets the binary stream.voidsetBlob(int arg0, InputStream arg1) Sets the blob.voidsetBlob(int arg0, InputStream arg1, long arg2) Sets the blob.voidSets the blob.voidsetBoolean(int arg0, boolean arg1) Sets the boolean.voidsetByte(int arg0, byte arg1) Sets the byte.voidsetBytes(int arg0, byte[] arg1) Sets the bytes.voidsetCharacterStream(int arg0, Reader arg1) Sets the character stream.voidsetCharacterStream(int arg0, Reader arg1, int arg2) Sets the character stream.voidsetCharacterStream(int arg0, Reader arg1, long arg2) Sets the character stream.voidSets the clob.voidSets the clob.voidSets the clob.voidSets the date.voidSets the date.voidsetDouble(int arg0, double arg1) Sets the double.voidsetFloat(int arg0, float arg1) Sets the float.voidsetInt(int arg0, int arg1) Sets the int.voidsetLong(int arg0, long arg1) Sets the long.voidsetNCharacterStream(int arg0, Reader arg1) Sets the n character stream.voidsetNCharacterStream(int arg0, Reader arg1, long arg2) Sets the n character stream.voidSets the n clob.voidSets the n clob.voidSets the n clob.voidsetNString(int arg0, String arg1) Sets the n string.voidsetNull(int arg0, int arg1) Sets the null.voidSets the null.voidSets the object.voidSets the object.voidSets the object.voidSets the ref.voidSets the row id.voidsetShort(int arg0, short arg1) Sets the short.voidSets the sqlxml.voidSets the string.voidSets the time.voidSets the time.voidsetTimestamp(int arg0, Timestamp arg1) Sets the timestamp.voidsetTimestamp(int arg0, Timestamp arg1, Calendar arg2) Sets the timestamp.voidsetUnicodeStream(int arg0, InputStream arg1, int arg2) Sets the unicode stream.voidSets the url.toString()We want to return the real SQL as string represenation.Methods inherited from class clazzfish.jdbc.internal.StasiStatement
addBatch, cancel, clearBatch, clearWarnings, closeOnCompletion, enrichedSQLException, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getCallerStacktrace, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getStatement, getUpdateCount, getUpdated, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, saveUpdateStatistic, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.sql.PreparedStatement
executeLargeUpdate, setObject, setObjectMethods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, 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, setQueryTimeoutMethods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Constructor Details
-
StasiPreparedStatement
Instantiates a new stasi prepared statement.- Parameters:
statement- the statementargs- the arguments for the creation of thePreparedStatement
-
-
Method Details
-
getWrappedPreparedStatement
In some cicrumstances you may want to acces the originalPreparedStatementdirectly. Use this method to get it.- Returns:
- the wrapped
PreparedStatement - Since:
- 1.6.2
-
addBatch
Adds the batch.- Specified by:
addBatchin interfacePreparedStatement- Throws:
SQLException- the sQL exception- See Also:
-
clearParameters
Clear parameters.- Specified by:
clearParametersin interfacePreparedStatement- Throws:
SQLException- the sQL exception- See Also:
-
close
Close the statement. Because we want to log the SQL we do not call the superclass here but do the close ourself.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Overrides:
closein classStasiStatement- Throws:
SQLException- the sQL exception- See Also:
-
execute
Execute.- Specified by:
executein interfacePreparedStatement- Returns:
- true, if successful
- Throws:
SQLException- the sQL exception- See Also:
-
executeQuery
Execute query.NOTE: The
ResultSetwhich is returned by this method must be closed by the caller.- Specified by:
executeQueryin interfacePreparedStatement- Returns:
- an open result set
- Throws:
SQLException- in case of DB problems- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdatein interfacePreparedStatement- Returns:
- the int
- Throws:
SQLException- the sQL exception- See Also:
-
getMetaData
Gets the meta data.- Specified by:
getMetaDatain interfacePreparedStatement- Returns:
- the meta data
- Throws:
SQLException- the sQL exception- See Also:
-
getParameterMetaData
Gets the parameter meta data.- Specified by:
getParameterMetaDatain interfacePreparedStatement- Returns:
- the parameter meta data
- Throws:
SQLException- the sQL exception- See Also:
-
setArray
Sets the array.- Specified by:
setArrayin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBigDecimal
Sets the big decimal.- Specified by:
setBigDecimalin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBoolean
Sets the boolean.- Specified by:
setBooleanin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setByte
Sets the byte.- Specified by:
setBytein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setBytes
Sets the bytes.- Specified by:
setBytesin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setDate
Sets the date.- Specified by:
setDatein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setDate
Sets the date.- Specified by:
setDatein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setDouble
Sets the double.- Specified by:
setDoublein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setFloat
Sets the float.- Specified by:
setFloatin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setInt
Sets the int.- Specified by:
setIntin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setLong
Sets the long.- Specified by:
setLongin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setNCharacterStream
Sets the n character stream.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setNCharacterStream
Sets the n character stream.- Specified by:
setNCharacterStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClobin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setNString
Sets the n string.- Specified by:
setNStringin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setNull
Sets the null.- Specified by:
setNullin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setNull
Sets the null.- Specified by:
setNullin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2arg3- the arg3- Throws:
SQLException- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObjectin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setRef
Sets the ref.- Specified by:
setRefin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setRowId
Sets the row id.- Specified by:
setRowIdin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setSQLXML
Sets the sqlxml.- Specified by:
setSQLXMLin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setShort
Sets the short.- Specified by:
setShortin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setString
Sets the string.- Specified by:
setStringin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setTime
Sets the time.- Specified by:
setTimein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setTime
Sets the time.- Specified by:
setTimein interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception- See Also:
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestampin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setURL
Sets the url.- Specified by:
setURLin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1- Throws:
SQLException- the sQL exception- See Also:
-
setUnicodeStream
Sets the unicode stream.- Specified by:
setUnicodeStreamin interfacePreparedStatement- Parameters:
arg0- the arg0arg1- the arg1arg2- the arg2- Throws:
SQLException- the sQL exception
-
toString
We want to return the real SQL as string represenation.- Overrides:
toStringin classStasiStatement- Returns:
- the string
- See Also:
-