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 TypeMethodDescriptionvoid
addBatch()
Adds the batch.void
Clear parameters.void
close()
Close the statement.boolean
execute()
Execute.Execute query.int
Execute update.Gets the meta data.Gets the parameter meta data.In some cicrumstances you may want to acces the originalPreparedStatement
directly.void
Sets the array.void
setAsciiStream
(int arg0, InputStream arg1) Sets the ascii stream.void
setAsciiStream
(int arg0, InputStream arg1, int arg2) Sets the ascii stream.void
setAsciiStream
(int arg0, InputStream arg1, long arg2) Sets the ascii stream.void
setBigDecimal
(int arg0, BigDecimal arg1) Sets the big decimal.void
setBinaryStream
(int arg0, InputStream arg1) Sets the binary stream.void
setBinaryStream
(int arg0, InputStream arg1, int arg2) Sets the binary stream.void
setBinaryStream
(int arg0, InputStream arg1, long arg2) Sets the binary stream.void
setBlob
(int arg0, InputStream arg1) Sets the blob.void
setBlob
(int arg0, InputStream arg1, long arg2) Sets the blob.void
Sets the blob.void
setBoolean
(int arg0, boolean arg1) Sets the boolean.void
setByte
(int arg0, byte arg1) Sets the byte.void
setBytes
(int arg0, byte[] arg1) Sets the bytes.void
setCharacterStream
(int arg0, Reader arg1) Sets the character stream.void
setCharacterStream
(int arg0, Reader arg1, int arg2) Sets the character stream.void
setCharacterStream
(int arg0, Reader arg1, long arg2) Sets the character stream.void
Sets the clob.void
Sets the clob.void
Sets the clob.void
Sets the date.void
Sets the date.void
setDouble
(int arg0, double arg1) Sets the double.void
setFloat
(int arg0, float arg1) Sets the float.void
setInt
(int arg0, int arg1) Sets the int.void
setLong
(int arg0, long arg1) Sets the long.void
setNCharacterStream
(int arg0, Reader arg1) Sets the n character stream.void
setNCharacterStream
(int arg0, Reader arg1, long arg2) Sets the n character stream.void
Sets the n clob.void
Sets the n clob.void
Sets the n clob.void
setNString
(int arg0, String arg1) Sets the n string.void
setNull
(int arg0, int arg1) Sets the null.void
Sets the null.void
Sets the object.void
Sets the object.void
Sets the object.void
Sets the ref.void
Sets the row id.void
setShort
(int arg0, short arg1) Sets the short.void
Sets the sqlxml.void
Sets the string.void
Sets the time.void
Sets the time.void
setTimestamp
(int arg0, Timestamp arg1) Sets the timestamp.void
setTimestamp
(int arg0, Timestamp arg1, Calendar arg2) Sets the timestamp.void
setUnicodeStream
(int arg0, InputStream arg1, int arg2) Sets the unicode stream.void
Sets 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, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.sql.PreparedStatement
executeLargeUpdate, setObject, setObject
Methods 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, setQueryTimeout
Methods 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 originalPreparedStatement
directly. Use this method to get it.- Returns:
- the wrapped
PreparedStatement
- Since:
- 1.6.2
-
addBatch
Adds the batch.- Specified by:
addBatch
in interfacePreparedStatement
- Throws:
SQLException
- the sQL exception- See Also:
-
clearParameters
Clear parameters.- Specified by:
clearParameters
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Overrides:
close
in classStasiStatement
- Throws:
SQLException
- the sQL exception- See Also:
-
execute
Execute.- Specified by:
execute
in interfacePreparedStatement
- Returns:
- true, if successful
- Throws:
SQLException
- the sQL exception- See Also:
-
executeQuery
Execute query.NOTE: The
ResultSet
which is returned by this method must be closed by the caller.- Specified by:
executeQuery
in interfacePreparedStatement
- Returns:
- an open result set
- Throws:
SQLException
- in case of DB problems- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdate
in interfacePreparedStatement
- Returns:
- the int
- Throws:
SQLException
- the sQL exception- See Also:
-
getMetaData
Gets the meta data.- Specified by:
getMetaData
in interfacePreparedStatement
- Returns:
- the meta data
- Throws:
SQLException
- the sQL exception- See Also:
-
getParameterMetaData
Gets the parameter meta data.- Specified by:
getParameterMetaData
in interfacePreparedStatement
- Returns:
- the parameter meta data
- Throws:
SQLException
- the sQL exception- See Also:
-
setArray
Sets the array.- Specified by:
setArray
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setAsciiStream
Sets the ascii stream.- Specified by:
setAsciiStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBigDecimal
Sets the big decimal.- Specified by:
setBigDecimal
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setBinaryStream
Sets the binary stream.- Specified by:
setBinaryStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setBlob
Sets the blob.- Specified by:
setBlob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBoolean
Sets the boolean.- Specified by:
setBoolean
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setByte
Sets the byte.- Specified by:
setByte
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setBytes
Sets the bytes.- Specified by:
setBytes
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setCharacterStream
Sets the character stream.- Specified by:
setCharacterStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setClob
Sets the clob.- Specified by:
setClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setDate
Sets the date.- Specified by:
setDate
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setDate
Sets the date.- Specified by:
setDate
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setDouble
Sets the double.- Specified by:
setDouble
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setFloat
Sets the float.- Specified by:
setFloat
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setInt
Sets the int.- Specified by:
setInt
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setLong
Sets the long.- Specified by:
setLong
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setNCharacterStream
Sets the n character stream.- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setNCharacterStream
Sets the n character stream.- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setNClob
Sets the n clob.- Specified by:
setNClob
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setNString
Sets the n string.- Specified by:
setNString
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setNull
Sets the null.- Specified by:
setNull
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setNull
Sets the null.- Specified by:
setNull
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObject
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2arg3
- the arg3- Throws:
SQLException
- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObject
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setObject
Sets the object.- Specified by:
setObject
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setRef
Sets the ref.- Specified by:
setRef
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setRowId
Sets the row id.- Specified by:
setRowId
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setSQLXML
Sets the sqlxml.- Specified by:
setSQLXML
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setShort
Sets the short.- Specified by:
setShort
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setString
Sets the string.- Specified by:
setString
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setTime
Sets the time.- Specified by:
setTime
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setTime
Sets the time.- Specified by:
setTime
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestamp
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1arg2
- the arg2- Throws:
SQLException
- the sQL exception- See Also:
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestamp
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setURL
Sets the url.- Specified by:
setURL
in interfacePreparedStatement
- Parameters:
arg0
- the arg0arg1
- the arg1- Throws:
SQLException
- the sQL exception- See Also:
-
setUnicodeStream
Sets the unicode stream.- Specified by:
setUnicodeStream
in 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:
toString
in classStasiStatement
- Returns:
- the string
- See Also:
-