|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jolbox.bonecp.StatementHandle
public class StatementHandle
Wrapper around JDBC Statement.
| Field Summary | |
|---|---|
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. |
protected boolean |
enqueuedForClosure
If true, this statement is being closed off by a separate thread. |
boolean |
inCache
If true, this statement is in the cache. |
protected Statement |
internalStatement
A handle to the actual statement. |
protected static org.slf4j.Logger |
logger
Class logger. |
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. |
| 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 | |
|---|---|
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. |
|
| Method Summary | ||
|---|---|---|
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()
|
|
protected void |
closeStatement()
Closes off the statement |
|
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 |
isClosedOrEnqueuedForClosure()
Return true if statement is closed or is enqueued for closure. |
|
boolean |
isEnqueuedForClosure()
Returns the enqueuedForClosure field. |
|
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()
|
|
protected boolean |
tryTransferOffer(StatementHandle e)
Tries to move the item to a waiting consumer. |
|
|
unwrap(Class<T> iface)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
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 static org.slf4j.Logger logger
protected long queryExecuteTimeLimit
protected ConnectionHook connectionHook
protected volatile boolean enqueuedForClosure
protected Map<Object,Object> logParams
protected StringBuilder batchSQL
| Constructor Detail |
|---|
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.| Method Detail |
|---|
protected void closeStatement()
throws SQLException
SQLExceptionprotected boolean tryTransferOffer(StatementHandle e)
e - Item to transfer
public void close()
throws SQLException
close in interface StatementSQLException
public 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()
isClosed in interface Statement
public void setPoolable(boolean poolable)
throws SQLException
setPoolable in interface StatementSQLException
public boolean isWrapperFor(Class<?> iface)
throws SQLException
isWrapperFor in interface WrapperSQLException
public <T> T unwrap(Class<T> iface)
throws SQLException
unwrap in interface WrapperSQLException
public boolean isPoolable()
throws SQLException
isPoolable in interface StatementSQLException
public void setCursorName(String name)
throws SQLException
setCursorName in interface StatementSQLException
public 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 toString()
toString in class Objectpublic 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()
public boolean isEnqueuedForClosure()
public boolean isClosedOrEnqueuedForClosure()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||