patterntesting.runtime.monitor.db.internal
Class StasiStatement

Package class diagram package StasiStatement
java.lang.Object
  extended by patterntesting.runtime.monitor.db.internal.StasiStatement
All Implemented Interfaces:
Statement, Wrapper
Direct Known Subclasses:
StasiPreparedStatement

public class StasiStatement
extends Object
implements Statement

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.4 $
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
StasiStatement(Statement statement)
          Instantiates a new proxy statement.
 
Method Summary
 void addBatch(String sql)
          Adds the batch.
 void cancel()
          Cancel.
 void clearBatch()
          Clear batch.
 void clearWarnings()
          Clear warnings.
 void close()
          Close.
 void closeOnCompletion()
          Close on completion.
protected  SQLException enrichedSQLException(ProfileMonitor mon, String sql, SQLException original)
          For better error analysis the original SQLException will be enriched with some additional infos.
 boolean execute(String sql)
          Execute.
 boolean execute(String sql, int autoGeneratedKeys)
          Execute.
 boolean execute(String sql, int[] columnIndexes)
          Execute.
 boolean execute(String sql, String[] columnNames)
          Execute.
 int[] executeBatch()
          Execute batch.
 ResultSet executeQuery(String sql)
          Execute query.
 int executeUpdate(String sql)
          Execute update.
 int executeUpdate(String sql, int autoGeneratedKeys)
          Execute update.
 int executeUpdate(String sql, int[] columnIndexes)
          Execute update.
 int executeUpdate(String sql, String[] columnNames)
          Execute update.
 Connection getConnection()
          Gets the connection.
 int getFetchDirection()
          Gets the fetch direction.
 int getFetchSize()
          Gets the fetch size.
 ResultSet getGeneratedKeys()
          Gets the generated keys.
 int getMaxFieldSize()
          Gets the max field size.
 int getMaxRows()
          Gets the max rows.
 boolean getMoreResults()
          Gets the more results.
 boolean getMoreResults(int current)
          Gets the more results.
 int getQueryTimeout()
          Gets the query timeout.
 ResultSet getResultSet()
          Gets the result set.
 int getResultSetConcurrency()
          Gets the result set concurrency.
 int getResultSetHoldability()
          Gets the result set holdability.
 int getResultSetType()
          Gets the result set type.
protected  Statement getStatement()
          Gets the statement.
 int getUpdateCount()
          Gets the update count.
 SQLWarning getWarnings()
          Gets the warnings.
 boolean isClosed()
          Checks if is closed.
 boolean isCloseOnCompletion()
          Checks if is close on completion.
 boolean isPoolable()
          Checks if is poolable.
 boolean isWrapperFor(Class<?> arg0)
          Checks if is wrapper for.
 void setCursorName(String name)
          Sets the cursor name.
 void setEscapeProcessing(boolean enable)
          Sets the escape processing.
 void setFetchDirection(int direction)
          Sets the fetch direction.
 void setFetchSize(int rows)
          Sets the fetch size.
 void setMaxFieldSize(int max)
          Sets the max field size.
 void setMaxRows(int max)
          Sets the max rows.
 void setPoolable(boolean poolable)
          Sets the poolable.
 void setQueryTimeout(int seconds)
          Sets the query timeout.
<T> T
unwrap(Class<T> arg0)
          Unwrap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StasiStatement

public StasiStatement(Statement statement)
Instantiates a new proxy statement.

Parameters:
statement - the statement
Method Detail

getStatement

protected final Statement getStatement()
Gets the statement.

Returns:
the statement

addBatch

public final void addBatch(String sql)
                    throws SQLException
Adds the batch.

Specified by:
addBatch in interface Statement
Parameters:
sql - the sql
Throws:
SQLException - the sQL exception
See Also:
Statement.addBatch(java.lang.String)

cancel

public final void cancel()
                  throws SQLException
Cancel.

Specified by:
cancel in interface Statement
Throws:
SQLException - the sQL exception
See Also:
Statement.cancel()

clearBatch

public final void clearBatch()
                      throws SQLException
Clear batch.

Specified by:
clearBatch in interface Statement
Throws:
SQLException - the sQL exception
See Also:
Statement.clearBatch()

clearWarnings

public final void clearWarnings()
                         throws SQLException
Clear warnings.

Specified by:
clearWarnings in interface Statement
Throws:
SQLException - the sQL exception
See Also:
Statement.clearWarnings()

close

public void close()
           throws SQLException
Close.

Specified by:
close in interface Statement
Throws:
SQLException - the sQL exception
See Also:
Statement.close()

execute

public final boolean execute(String sql,
                             int autoGeneratedKeys)
                      throws SQLException
Execute.

Specified by:
execute in interface Statement
Parameters:
sql - the sql
autoGeneratedKeys - the auto generated keys
Returns:
true, if successful
Throws:
SQLException - the sQL exception
See Also:
Statement.execute(java.lang.String, int)

execute

public final boolean execute(String sql,
                             int[] columnIndexes)
                      throws SQLException
Execute.

Specified by:
execute in interface Statement
Parameters:
sql - the sql
columnIndexes - the column indexes
Returns:
true, if successful
Throws:
SQLException - the sQL exception
See Also:
Statement.execute(java.lang.String, int[])

execute

public final boolean execute(String sql,
                             String[] columnNames)
                      throws SQLException
Execute.

Specified by:
execute in interface Statement
Parameters:
sql - the sql
columnNames - the column names
Returns:
true, if successful
Throws:
SQLException - the sQL exception
See Also:
Statement.execute(java.lang.String, java.lang.String[])

execute

public final boolean execute(String sql)
                      throws SQLException
Execute.

Specified by:
execute in interface Statement
Parameters:
sql - the sql
Returns:
true, if successful
Throws:
SQLException - the sQL exception
See Also:
Statement.execute(java.lang.String)

executeBatch

public final int[] executeBatch()
                         throws SQLException
Execute batch.

Specified by:
executeBatch in interface Statement
Returns:
the int[]
Throws:
SQLException - the sQL exception
See Also:
Statement.executeBatch()

executeQuery

public final ResultSet executeQuery(String sql)
                             throws SQLException
Execute query.

Specified by:
executeQuery in interface Statement
Parameters:
sql - the sql
Returns:
the result set
Throws:
SQLException - the sQL exception
See Also:
Statement.executeQuery(java.lang.String)

executeUpdate

public final int executeUpdate(String sql,
                               int autoGeneratedKeys)
                        throws SQLException
Execute update.

Specified by:
executeUpdate in interface Statement
Parameters:
sql - the sql
autoGeneratedKeys - the auto generated keys
Returns:
the int
Throws:
SQLException - the sQL exception
See Also:
Statement.executeUpdate(java.lang.String, int)

executeUpdate

public final int executeUpdate(String sql,
                               int[] columnIndexes)
                        throws SQLException
Execute update.

Specified by:
executeUpdate in interface Statement
Parameters:
sql - the sql
columnIndexes - the column indexes
Returns:
the int
Throws:
SQLException - the sQL exception
See Also:
Statement.executeUpdate(java.lang.String, int[])

executeUpdate

public final int executeUpdate(String sql,
                               String[] columnNames)
                        throws SQLException
Execute update.

Specified by:
executeUpdate in interface Statement
Parameters:
sql - the sql
columnNames - the column names
Returns:
the int
Throws:
SQLException - the sQL exception
See Also:
Statement.executeUpdate(java.lang.String, java.lang.String[])

executeUpdate

public final int executeUpdate(String sql)
                        throws SQLException
Execute update.

Specified by:
executeUpdate in interface Statement
Parameters:
sql - the sql
Returns:
the int
Throws:
SQLException - the sQL exception
See Also:
Statement.executeUpdate(java.lang.String)

enrichedSQLException

protected SQLException enrichedSQLException(ProfileMonitor mon,
                                            String sql,
                                            SQLException original)
For better error analysis the original SQLException will be enriched with some additional infos.

Parameters:
mon - the mon
sql - the sql
original - the original
Returns:
the sQL exception

getConnection

public final Connection getConnection()
                               throws SQLException
Gets the connection.

Specified by:
getConnection in interface Statement
Returns:
the connection
Throws:
SQLException - the sQL exception
See Also:
Statement.getConnection()

getFetchDirection

public final int getFetchDirection()
                            throws SQLException
Gets the fetch direction.

Specified by:
getFetchDirection in interface Statement
Returns:
the fetch direction
Throws:
SQLException - the sQL exception
See Also:
Statement.getFetchDirection()

getFetchSize

public final int getFetchSize()
                       throws SQLException
Gets the fetch size.

Specified by:
getFetchSize in interface Statement
Returns:
the fetch size
Throws:
SQLException - the sQL exception
See Also:
Statement.getFetchSize()

getGeneratedKeys

public final ResultSet getGeneratedKeys()
                                 throws SQLException
Gets the generated keys.

Specified by:
getGeneratedKeys in interface Statement
Returns:
the generated keys
Throws:
SQLException - the sQL exception
See Also:
Statement.getGeneratedKeys()

getMaxFieldSize

public final int getMaxFieldSize()
                          throws SQLException
Gets the max field size.

Specified by:
getMaxFieldSize in interface Statement
Returns:
the max field size
Throws:
SQLException - the sQL exception
See Also:
Statement.getMaxFieldSize()

getMaxRows

public final int getMaxRows()
                     throws SQLException
Gets the max rows.

Specified by:
getMaxRows in interface Statement
Returns:
the max rows
Throws:
SQLException - the sQL exception
See Also:
Statement.getMaxRows()

getMoreResults

public final boolean getMoreResults()
                             throws SQLException
Gets the more results.

Specified by:
getMoreResults in interface Statement
Returns:
the more results
Throws:
SQLException - the sQL exception
See Also:
Statement.getMoreResults()

getMoreResults

public final boolean getMoreResults(int current)
                             throws SQLException
Gets the more results.

Specified by:
getMoreResults in interface Statement
Parameters:
current - the current
Returns:
the more results
Throws:
SQLException - the sQL exception
See Also:
Statement.getMoreResults(int)

getQueryTimeout

public final int getQueryTimeout()
                          throws SQLException
Gets the query timeout.

Specified by:
getQueryTimeout in interface Statement
Returns:
the query timeout
Throws:
SQLException - the sQL exception
See Also:
Statement.getQueryTimeout()

getResultSet

public final ResultSet getResultSet()
                             throws SQLException
Gets the result set.

Specified by:
getResultSet in interface Statement
Returns:
the result set
Throws:
SQLException - the sQL exception
See Also:
Statement.getResultSet()

getResultSetConcurrency

public final int getResultSetConcurrency()
                                  throws SQLException
Gets the result set concurrency.

Specified by:
getResultSetConcurrency in interface Statement
Returns:
the result set concurrency
Throws:
SQLException - the sQL exception
See Also:
Statement.getResultSetConcurrency()

getResultSetHoldability

public final int getResultSetHoldability()
                                  throws SQLException
Gets the result set holdability.

Specified by:
getResultSetHoldability in interface Statement
Returns:
the result set holdability
Throws:
SQLException - the sQL exception
See Also:
Statement.getResultSetHoldability()

getResultSetType

public final int getResultSetType()
                           throws SQLException
Gets the result set type.

Specified by:
getResultSetType in interface Statement
Returns:
the result set type
Throws:
SQLException - the sQL exception
See Also:
Statement.getResultSetType()

getUpdateCount

public final int getUpdateCount()
                         throws SQLException
Gets the update count.

Specified by:
getUpdateCount in interface Statement
Returns:
the update count
Throws:
SQLException - the sQL exception
See Also:
Statement.getUpdateCount()

getWarnings

public final SQLWarning getWarnings()
                             throws SQLException
Gets the warnings.

Specified by:
getWarnings in interface Statement
Returns:
the warnings
Throws:
SQLException - the sQL exception
See Also:
Statement.getWarnings()

isClosed

public final boolean isClosed()
                       throws SQLException
Checks if is closed.

Specified by:
isClosed in interface Statement
Returns:
true, if is closed
Throws:
SQLException - the sQL exception
See Also:
Statement.isClosed()

isPoolable

public final boolean isPoolable()
                         throws SQLException
Checks if is poolable.

Specified by:
isPoolable in interface Statement
Returns:
true, if is poolable
Throws:
SQLException - the sQL exception
See Also:
Statement.isPoolable()

isWrapperFor

public final boolean isWrapperFor(Class<?> arg0)
                           throws SQLException
Checks if is wrapper for.

Specified by:
isWrapperFor in interface Wrapper
Parameters:
arg0 - the arg0
Returns:
true, if is wrapper for
Throws:
SQLException - the sQL exception
See Also:
Wrapper.isWrapperFor(java.lang.Class)

setCursorName

public final void setCursorName(String name)
                         throws SQLException
Sets the cursor name.

Specified by:
setCursorName in interface Statement
Parameters:
name - the new cursor name
Throws:
SQLException - the sQL exception
See Also:
Statement.setCursorName(java.lang.String)

setEscapeProcessing

public final void setEscapeProcessing(boolean enable)
                               throws SQLException
Sets the escape processing.

Specified by:
setEscapeProcessing in interface Statement
Parameters:
enable - the new escape processing
Throws:
SQLException - the sQL exception
See Also:
Statement.setEscapeProcessing(boolean)

setFetchDirection

public final void setFetchDirection(int direction)
                             throws SQLException
Sets the fetch direction.

Specified by:
setFetchDirection in interface Statement
Parameters:
direction - the new fetch direction
Throws:
SQLException - the sQL exception
See Also:
Statement.setFetchDirection(int)

setFetchSize

public final void setFetchSize(int rows)
                        throws SQLException
Sets the fetch size.

Specified by:
setFetchSize in interface Statement
Parameters:
rows - the new fetch size
Throws:
SQLException - the sQL exception
See Also:
Statement.setFetchSize(int)

setMaxFieldSize

public final void setMaxFieldSize(int max)
                           throws SQLException
Sets the max field size.

Specified by:
setMaxFieldSize in interface Statement
Parameters:
max - the new max field size
Throws:
SQLException - the sQL exception
See Also:
Statement.setMaxFieldSize(int)

setMaxRows

public final void setMaxRows(int max)
                      throws SQLException
Sets the max rows.

Specified by:
setMaxRows in interface Statement
Parameters:
max - the new max rows
Throws:
SQLException - the sQL exception
See Also:
Statement.setMaxRows(int)

setPoolable

public final void setPoolable(boolean poolable)
                       throws SQLException
Sets the poolable.

Specified by:
setPoolable in interface Statement
Parameters:
poolable - the new poolable
Throws:
SQLException - the sQL exception
See Also:
Statement.setPoolable(boolean)

setQueryTimeout

public final void setQueryTimeout(int seconds)
                           throws SQLException
Sets the query timeout.

Specified by:
setQueryTimeout in interface Statement
Parameters:
seconds - the new query timeout
Throws:
SQLException - the sQL exception
See Also:
Statement.setQueryTimeout(int)

unwrap

public final <T> T unwrap(Class<T> arg0)
               throws SQLException
Unwrap.

Specified by:
unwrap in interface Wrapper
Type Parameters:
T - the generic type
Parameters:
arg0 - the arg0
Returns:
the t
Throws:
SQLException - the sQL exception
See Also:
Wrapper.unwrap(java.lang.Class)

closeOnCompletion

public final void closeOnCompletion()
                             throws SQLException
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.

Throws:
SQLException - the SQL exception
Since:
Java 7

isCloseOnCompletion

public final boolean isCloseOnCompletion()
                                  throws SQLException
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.

Returns:
true, if is close on completion
Throws:
SQLException - the SQL exception
Since:
Java 7


Copyright © 2002–2014 PatternTesting Team. All rights reserved.