Class StasiStatement
java.lang.Object
clazzfish.jdbc.internal.StasiStatement
- All Implemented Interfaces:
AutoCloseable,Statement,Wrapper
- Direct Known Subclasses:
StasiPreparedStatement
A simple wrapper for
Statement 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 StasiStatement controls the embedded Statement - therefore the
name.
- Since:
- 1.4.1 (16.03.2014)
- Version:
- $Revision: 1.13 $
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdds the batch.final voidcancel()Cancel.final voidClear batch.final voidClear warnings.voidclose()Close.final voidClose on completion.protected SQLExceptionenrichedSQLException(ProfileMonitor mon, String sql, SQLException original) For better error analysis the originalSQLExceptionwill be enriched with some additional infos.final booleanExecute.final booleanExecute.final booleanExecute.final booleanExecute.final int[]Execute batch.final ResultSetexecuteQuery(String sql) Execute query.final intexecuteUpdate(String sql) Execute update.final intexecuteUpdate(String sql, int autoGeneratedKeys) Execute update.final intexecuteUpdate(String sql, int[] columnIndexes) Execute update.final intexecuteUpdate(String sql, String[] columnNames) Execute update.static StackTraceElement[]getCallerStacktrace(Class<?>... ignoredClasses) Gets the caller stacktrace.final ConnectionGets the connection.final intGets the fetch direction.final intGets the fetch size.final ResultSetGets the generated keys.longRetrieves the current result as an update count; if the result is aResultSetobject or there are no more results, -1 is returned.final intGets the max field size.final intGets the max rows.final booleanGets the more results.final booleangetMoreResults(int current) Gets the more results.final intGets the query timeout.final ResultSetGets the result set.final intGets the result set concurrency.final intGets the result set holdability.final intGets the result set type.protected final StatementGets the statement.final intGets the update count.intIf an entry was updated with one of the executeUpdate methods this method returns the number of updated entries.final SQLWarningGets the warnings.final booleanisClosed()Checks if is closed.final booleanChecks if is close on completion.final booleanChecks if is poolable.final booleanisWrapperFor(Class<?> arg0) Checks if is wrapper for.protected intsaveUpdateStatistic(ProfileMonitor mon, String sql, int rc) Save update statistic.final voidsetCursorName(String name) Sets the cursor name.final voidsetEscapeProcessing(boolean enable) Sets the escape processing.final voidsetFetchDirection(int direction) Sets the fetch direction.final voidsetFetchSize(int rows) Sets the fetch size.final voidsetMaxFieldSize(int max) Sets the max field size.final voidsetMaxRows(int max) Sets the max rows.final voidsetPoolable(boolean poolable) Sets the poolable.final voidsetQueryTimeout(int seconds) Sets the query timeout.toString()To string.final <T> TUnwrap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, isSimpleIdentifier, setLargeMaxRows
-
Constructor Details
-
StasiStatement
Instantiates a new proxy statement.- Parameters:
statement- the statement
-
-
Method Details
-
getCallerStacktrace
Gets the caller stacktrace. To find the real caller we ignore the first 3 elements from the stacktrace because this is e.g. the methodThread.getStackTrace()which is not relevant here.- Parameters:
ignoredClasses- the ignored classes- Returns:
- the caller stacktrace
-
getUpdated
public int getUpdated()If an entry was updated with one of the executeUpdate methods this method returns the number of updated entries. Otherwise 0,- Returns:
- the number of updated entries (or 0)
- Since:
- 1.6.3
-
getStatement
-
addBatch
Adds the batch.- Specified by:
addBatchin interfaceStatement- Parameters:
sql- the sql- Throws:
SQLException- the SQL exception- See Also:
-
cancel
Cancel.- Specified by:
cancelin interfaceStatement- Throws:
SQLException- the sQL exception- See Also:
-
clearBatch
Clear batch.- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException- the sQL exception- See Also:
-
clearWarnings
Clear warnings.- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException- the sQL exception- See Also:
-
close
Close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException- the sQL exception- See Also:
-
execute
Execute.- Specified by:
executein interfaceStatement- Parameters:
sql- the sqlautoGeneratedKeys- the auto generated keys- Returns:
- true, if successful
- Throws:
SQLException- the sQL exception- See Also:
-
execute
Execute.- Specified by:
executein interfaceStatement- Parameters:
sql- the sqlcolumnIndexes- the column indexes- Returns:
- true, if successful
- Throws:
SQLException- the sQL exception- See Also:
-
execute
Execute.- Specified by:
executein interfaceStatement- Parameters:
sql- the sqlcolumnNames- the column names- Returns:
- true, if successful
- Throws:
SQLException- the sQL exception- See Also:
-
execute
Execute.- Specified by:
executein interfaceStatement- Parameters:
sql- the sql- Returns:
- true, if successful
- Throws:
SQLException- the sQL exception- See Also:
-
executeBatch
Execute batch.- Specified by:
executeBatchin interfaceStatement- Returns:
- the int[]
- Throws:
SQLException- the sQL exception- See Also:
-
executeQuery
Execute query.- Specified by:
executeQueryin interfaceStatement- Parameters:
sql- the sql- Returns:
- the result set
- Throws:
SQLException- the sQL exception- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdatein interfaceStatement- Parameters:
sql- the sqlautoGeneratedKeys- the auto generated keys- Returns:
- the int
- Throws:
SQLException- the sQL exception- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdatein interfaceStatement- Parameters:
sql- the sqlcolumnIndexes- the column indexes- Returns:
- the int
- Throws:
SQLException- the sQL exception- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdatein interfaceStatement- Parameters:
sql- the sqlcolumnNames- the column names- Returns:
- the int
- Throws:
SQLException- the sQL exception- See Also:
-
executeUpdate
Execute update.- Specified by:
executeUpdatein interfaceStatement- Parameters:
sql- the sql- Returns:
- the int
- Throws:
SQLException- the sQL exception- See Also:
-
saveUpdateStatistic
Save update statistic.- Parameters:
mon- the monitor for the statisticsql- the sqlrc- the return code (= number of updated entries)- Returns:
- the same as rc
-
enrichedSQLException
For better error analysis the originalSQLExceptionwill be enriched with some additional infos.- Parameters:
mon- the monsql- the sqloriginal- the original- Returns:
- the sQL exception
-
getConnection
Gets the connection.- Specified by:
getConnectionin interfaceStatement- Returns:
- the connection
- Throws:
SQLException- the sQL exception- See Also:
-
getFetchDirection
Gets the fetch direction.- Specified by:
getFetchDirectionin interfaceStatement- Returns:
- the fetch direction
- Throws:
SQLException- the sQL exception- See Also:
-
getFetchSize
Gets the fetch size.- Specified by:
getFetchSizein interfaceStatement- Returns:
- the fetch size
- Throws:
SQLException- the sQL exception- See Also:
-
getGeneratedKeys
Gets the generated keys.- Specified by:
getGeneratedKeysin interfaceStatement- Returns:
- the generated keys
- Throws:
SQLException- the sQL exception- See Also:
-
getMaxFieldSize
Gets the max field size.- Specified by:
getMaxFieldSizein interfaceStatement- Returns:
- the max field size
- Throws:
SQLException- the sQL exception- See Also:
-
getMaxRows
Gets the max rows.- Specified by:
getMaxRowsin interfaceStatement- Returns:
- the max rows
- Throws:
SQLException- the sQL exception- See Also:
-
getMoreResults
Gets the more results.- Specified by:
getMoreResultsin interfaceStatement- Returns:
- the more results
- Throws:
SQLException- the sQL exception- See Also:
-
getMoreResults
Gets the more results.- Specified by:
getMoreResultsin interfaceStatement- Parameters:
current- the current- Returns:
- the more results
- Throws:
SQLException- the sQL exception- See Also:
-
getQueryTimeout
Gets the query timeout.- Specified by:
getQueryTimeoutin interfaceStatement- Returns:
- the query timeout
- Throws:
SQLException- the sQL exception- See Also:
-
getResultSet
Gets the result set.- Specified by:
getResultSetin interfaceStatement- Returns:
- the result set
- Throws:
SQLException- the sQL exception- See Also:
-
getResultSetConcurrency
Gets the result set concurrency.- Specified by:
getResultSetConcurrencyin interfaceStatement- Returns:
- the result set concurrency
- Throws:
SQLException- the sQL exception- See Also:
-
getResultSetHoldability
Gets the result set holdability.- Specified by:
getResultSetHoldabilityin interfaceStatement- Returns:
- the result set holdability
- Throws:
SQLException- the sQL exception- See Also:
-
getResultSetType
Gets the result set type.- Specified by:
getResultSetTypein interfaceStatement- Returns:
- the result set type
- Throws:
SQLException- the sQL exception- See Also:
-
getUpdateCount
public final int getUpdateCount()Gets the update count. This method works always - wether the statemnt was closed or not.- Specified by:
getUpdateCountin interfaceStatement- Returns:
- the update count
- See Also:
-
getWarnings
Gets the warnings.- Specified by:
getWarningsin interfaceStatement- Returns:
- the warnings
- Throws:
SQLException- the sQL exception- See Also:
-
isClosed
Checks if is closed.- Specified by:
isClosedin interfaceStatement- Returns:
- true, if is closed
- Throws:
SQLException- the sQL exception- See Also:
-
isPoolable
Checks if is poolable.- Specified by:
isPoolablein interfaceStatement- Returns:
- true, if is poolable
- Throws:
SQLException- the sQL exception- See Also:
-
isWrapperFor
Checks if is wrapper for.- Specified by:
isWrapperForin interfaceWrapper- Parameters:
arg0- the arg0- Returns:
- true, if is wrapper for
- Throws:
SQLException- the sQL exception- See Also:
-
setCursorName
Sets the cursor name.- Specified by:
setCursorNamein interfaceStatement- Parameters:
name- the new cursor name- Throws:
SQLException- the sQL exception- See Also:
-
setEscapeProcessing
Sets the escape processing.- Specified by:
setEscapeProcessingin interfaceStatement- Parameters:
enable- the new escape processing- Throws:
SQLException- the sQL exception- See Also:
-
setFetchDirection
Sets the fetch direction.- Specified by:
setFetchDirectionin interfaceStatement- Parameters:
direction- the new fetch direction- Throws:
SQLException- the sQL exception- See Also:
-
setFetchSize
Sets the fetch size.- Specified by:
setFetchSizein interfaceStatement- Parameters:
rows- the new fetch size- Throws:
SQLException- the sQL exception- See Also:
-
setMaxFieldSize
Sets the max field size.- Specified by:
setMaxFieldSizein interfaceStatement- Parameters:
max- the new max field size- Throws:
SQLException- the sQL exception- See Also:
-
setMaxRows
Sets the max rows.- Specified by:
setMaxRowsin interfaceStatement- Parameters:
max- the new max rows- Throws:
SQLException- the sQL exception- See Also:
-
setPoolable
Sets the poolable.- Specified by:
setPoolablein interfaceStatement- Parameters:
poolable- the new poolable- Throws:
SQLException- the sQL exception- See Also:
-
setQueryTimeout
Sets the query timeout.- Specified by:
setQueryTimeoutin interfaceStatement- Parameters:
seconds- the new query timeout- Throws:
SQLException- the sQL exception- See Also:
-
unwrap
Unwrap.- Specified by:
unwrapin interfaceWrapper- Type Parameters:
T- the generic type- Parameters:
statementClass- the unwrapped statement class- Returns:
- the t
- Throws:
SQLException- the sQL exception- See Also:
-
closeOnCompletion
Close on completion. This method is not required for Java 6 and below but for Java 7. To be compatible with Java 6 this method has no implementation.- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException- the SQL exception- Since:
- Java 7
-
isCloseOnCompletion
Checks if is close on completion. This method is not required for Java 6 and below but for Java 7. To be compatible with Java 6 this method has no implementation.- Specified by:
isCloseOnCompletionin interfaceStatement- Returns:
- true, if is close on completion
- Throws:
SQLException- the SQL exception- Since:
- Java 7
-
getLargeUpdateCount
Retrieves the current result as an update count; if the result is aResultSetobject or there are no more results, -1 is returned. This method should be called only once per result.This method should be used when the returned row count may exceed
Integer.MAX_VALUE.- Specified by:
getLargeUpdateCountin interfaceStatement- Returns:
- the current result as an update count; -1 if the current result
is a
ResultSetobject or there are no more results - Throws:
SQLException- if a database access error occurs or this method is called on a closedStatement- Since:
- Java 8
- See Also:
-
toString
-