public class StatementHandle extends Object implements Statement
| Modifier and Type | Field and Description |
|---|---|
protected StringBuilder |
batchSQL
for logging of addBatch.
|
protected IStatementCache |
cache
Cache pertaining to this statement.
|
protected ConnectionHandle |
connectionHandle
Handle to the connection holding this statement.
|
protected ConnectionHook |
connectionHook
Config setting.
|
boolean |
inCache
If true, this statement is in the cache.
|
protected Statement |
internalStatement
A handle to the actual statement.
|
protected AtomicBoolean |
logicallyClosed
Set to true if the connection has been "closed".
|
protected Map<Object,Object> |
logParams
For logging purposes - stores parameters to be used for execution.
|
protected boolean |
logStatementsEnabled
If enabled, log all statements being executed.
|
String |
openStackTrace
Stack trace capture of where this statement was opened.
|
protected long |
queryExecuteTimeLimit
Config setting converted to nanoseconds.
|
protected String |
sql
SQL Statement used for this statement.
|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Constructor and Description |
|---|
StatementHandle(Statement internalStatement,
ConnectionHandle connectionHandle,
boolean logStatementsEnabled)
Constructor for empty statement (created via connection.createStatement)
|
StatementHandle(Statement internalStatement,
String sql,
IStatementCache cache,
ConnectionHandle connectionHandle,
String cacheKey,
boolean logStatementsEnabled)
Constructor to statement handle wrapper.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch(String sql) |
void |
cancel() |
protected void |
checkClosed()
Checks if the connection is marked as being logically open and throws an exception if not.
|
void |
clearBatch() |
protected void |
clearCache()
Clears out the cache of statements.
|
void |
clearWarnings() |
void |
close() |
void |
closeOnCompletion() |
boolean |
execute(String sql) |
boolean |
execute(String sql,
int autoGeneratedKeys) |
boolean |
execute(String sql,
int[] columnIndexes) |
boolean |
execute(String sql,
String[] columnNames) |
int[] |
executeBatch() |
ResultSet |
executeQuery(String sql) |
int |
executeUpdate(String sql) |
int |
executeUpdate(String sql,
int autoGeneratedKeys) |
int |
executeUpdate(String sql,
int[] columnIndexes) |
int |
executeUpdate(String sql,
String[] columnNames) |
Connection |
getConnection() |
Object |
getDebugHandle()
Returns the debugHandle field.
|
int |
getFetchDirection() |
int |
getFetchSize() |
ResultSet |
getGeneratedKeys() |
Statement |
getInternalStatement()
Returns the statement being wrapped around by this wrapper.
|
int |
getMaxFieldSize() |
int |
getMaxRows() |
boolean |
getMoreResults() |
boolean |
getMoreResults(int current) |
String |
getOpenStackTrace()
Returns the stack trace where this statement was first opened.
|
int |
getQueryTimeout() |
ResultSet |
getResultSet() |
int |
getResultSetConcurrency() |
int |
getResultSetHoldability() |
int |
getResultSetType() |
int |
getUpdateCount() |
SQLWarning |
getWarnings() |
boolean |
isClosed()
Returns true if statement is logically closed
|
boolean |
isCloseOnCompletion() |
boolean |
isPoolable() |
boolean |
isWrapperFor(Class<?> iface) |
protected void |
queryTimerEnd(String sql,
long queryStartTime)
Call the onQueryExecuteTimeLimitExceeded hook if necessary
|
protected long |
queryTimerStart()
Start off a timer if necessary
|
void |
setCursorName(String name) |
void |
setDebugHandle(Object debugHandle)
Sets a debugHandle, an object that is not used by the connection pool at all but may be set by an application to track
this particular connection handle for any purpose it deems fit.
|
void |
setEscapeProcessing(boolean enable) |
void |
setFetchDirection(int direction) |
void |
setFetchSize(int rows) |
void |
setInternalStatement(Statement internalStatement)
Sets the internal statement used by this wrapper.
|
protected void |
setLogicallyOpen()
Marks this statement as being "open"
|
void |
setMaxFieldSize(int max) |
void |
setMaxRows(int max) |
void |
setOpenStackTrace(String openStackTrace)
Sets the stack trace where this statement was first opened.
|
void |
setPoolable(boolean poolable) |
void |
setQueryTimeout(int seconds) |
String |
toString() |
<T> T |
unwrap(Class<T> iface) |
protected AtomicBoolean logicallyClosed
protected Statement internalStatement
protected String sql
protected IStatementCache cache
protected ConnectionHandle connectionHandle
protected boolean logStatementsEnabled
public volatile boolean inCache
public String openStackTrace
protected long queryExecuteTimeLimit
protected ConnectionHook connectionHook
protected Map<Object,Object> logParams
protected StringBuilder batchSQL
public StatementHandle(Statement internalStatement, String sql, IStatementCache cache, ConnectionHandle connectionHandle, String cacheKey, boolean logStatementsEnabled)
internalStatement - handle to actual statement instance.sql - statement used for this handle.cache - Cache handleconnectionHandle - Handle to the connectioncacheKey - logStatementsEnabled - set to true to log statements.public StatementHandle(Statement internalStatement, ConnectionHandle connectionHandle, boolean logStatementsEnabled)
internalStatement - wrapper to statementconnectionHandle - Handle to the connection that this statement is tied to.logStatementsEnabled - set to true to enable sql logging.public void close()
throws SQLException
close in interface AutoCloseableclose in interface StatementSQLExceptionpublic void addBatch(String sql) throws SQLException
addBatch in interface StatementSQLExceptionStatement.addBatch(java.lang.String)protected void checkClosed()
throws SQLException
SQLException - if connection is marked as logically closed.public void cancel()
throws SQLException
cancel in interface StatementSQLExceptionStatement.cancel()public void clearBatch()
throws SQLException
clearBatch in interface StatementSQLExceptionStatement.clearBatch()public void clearWarnings()
throws SQLException
clearWarnings in interface StatementSQLExceptionStatement.clearWarnings()public boolean execute(String sql) throws SQLException
execute in interface StatementSQLExceptionStatement.execute(java.lang.String)protected void queryTimerEnd(String sql, long queryStartTime)
sql - sql statement that took too longqueryStartTime - time when query was started.public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
execute in interface StatementSQLExceptionStatement.execute(java.lang.String, int)protected long queryTimerStart()
public boolean execute(String sql, int[] columnIndexes) throws SQLException
execute in interface StatementSQLExceptionStatement.execute(java.lang.String, int[])public boolean execute(String sql, String[] columnNames) throws SQLException
execute in interface StatementSQLExceptionStatement.execute(java.lang.String, java.lang.String[])public int[] executeBatch()
throws SQLException
executeBatch in interface StatementSQLExceptionStatement.executeBatch()public ResultSet executeQuery(String sql) throws SQLException
executeQuery in interface StatementSQLExceptionStatement.executeQuery(java.lang.String)public int executeUpdate(String sql) throws SQLException
executeUpdate in interface StatementSQLExceptionStatement.executeUpdate(java.lang.String)public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
executeUpdate in interface StatementSQLExceptionStatement.executeUpdate(java.lang.String, int)public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
executeUpdate in interface StatementSQLExceptionStatement.executeUpdate(java.lang.String, int[])public int executeUpdate(String sql, String[] columnNames) throws SQLException
executeUpdate in interface StatementSQLExceptionStatement.executeUpdate(java.lang.String, java.lang.String[])public Connection getConnection() throws SQLException
getConnection in interface StatementSQLExceptionStatement.getConnection()public int getFetchDirection()
throws SQLException
getFetchDirection in interface StatementSQLExceptionStatement.getFetchDirection()public int getFetchSize()
throws SQLException
getFetchSize in interface StatementSQLExceptionStatement.getFetchSize()public ResultSet getGeneratedKeys() throws SQLException
getGeneratedKeys in interface StatementSQLExceptionStatement.getGeneratedKeys()public int getMaxFieldSize()
throws SQLException
getMaxFieldSize in interface StatementSQLExceptionStatement.getMaxFieldSize()public int getMaxRows()
throws SQLException
getMaxRows in interface StatementSQLExceptionStatement.getMaxRows()public boolean getMoreResults()
throws SQLException
getMoreResults in interface StatementSQLExceptionStatement.getMoreResults()public boolean getMoreResults(int current)
throws SQLException
getMoreResults in interface StatementSQLExceptionStatement.getMoreResults(int)public int getQueryTimeout()
throws SQLException
getQueryTimeout in interface StatementSQLExceptionStatement.getQueryTimeout()public ResultSet getResultSet() throws SQLException
getResultSet in interface StatementSQLExceptionStatement.getResultSet()public int getResultSetConcurrency()
throws SQLException
getResultSetConcurrency in interface StatementSQLExceptionStatement.getResultSetConcurrency()public int getResultSetHoldability()
throws SQLException
getResultSetHoldability in interface StatementSQLExceptionStatement.getResultSetHoldability()public int getResultSetType()
throws SQLException
getResultSetType in interface StatementSQLExceptionStatement.getResultSetType()public int getUpdateCount()
throws SQLException
getUpdateCount in interface StatementSQLExceptionStatement.getUpdateCount()public SQLWarning getWarnings() throws SQLException
getWarnings in interface StatementSQLExceptionStatement.getWarnings()public boolean isClosed()
public void setPoolable(boolean poolable)
throws SQLException
setPoolable in interface StatementSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isPoolable()
throws SQLException
isPoolable in interface StatementSQLExceptionpublic void closeOnCompletion()
throws SQLException
closeOnCompletion in interface StatementSQLExceptionpublic boolean isCloseOnCompletion()
throws SQLException
isCloseOnCompletion in interface StatementSQLExceptionpublic void setCursorName(String name) throws SQLException
setCursorName in interface StatementSQLExceptionpublic void setEscapeProcessing(boolean enable)
throws SQLException
setEscapeProcessing in interface StatementSQLExceptionStatement.setEscapeProcessing(boolean)public void setFetchDirection(int direction)
throws SQLException
setFetchDirection in interface StatementSQLExceptionStatement.setFetchDirection(int)public void setFetchSize(int rows)
throws SQLException
setFetchSize in interface StatementSQLExceptionStatement.setFetchSize(int)public void setMaxFieldSize(int max)
throws SQLException
setMaxFieldSize in interface StatementSQLExceptionStatement.setMaxFieldSize(int)public void setMaxRows(int max)
throws SQLException
setMaxRows in interface StatementSQLExceptionStatement.setMaxRows(int)public void setQueryTimeout(int seconds)
throws SQLException
setQueryTimeout in interface StatementSQLExceptionStatement.setQueryTimeout(int)protected void clearCache()
protected void setLogicallyOpen()
public String getOpenStackTrace()
public void setOpenStackTrace(String openStackTrace)
openStackTrace - the openStackTrace to setpublic Statement getInternalStatement()
public void setInternalStatement(Statement internalStatement)
internalStatement - the internalStatement to setpublic void setDebugHandle(Object debugHandle)
debugHandle - any object.public Object getDebugHandle()
Copyright © 2009-2013 JolBox. All Rights Reserved.