com.jolbox.bonecp
Class StatementHandle

java.lang.Object
  extended by com.jolbox.bonecp.StatementHandle
All Implemented Interfaces:
java.sql.Statement, java.sql.Wrapper
Direct Known Subclasses:
PreparedStatementHandle

public class StatementHandle
extends java.lang.Object
implements java.sql.Statement

Wrapper around JDBC Statement.

Version:
$Revision$
Author:
wallacew

Field Summary
 boolean inCache
          If true, this statement is in the cache.
 java.lang.String openStackTrace
          Stack trace capture of where this statement was opened.
 
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(java.sql.Statement internalStatement, ConnectionHandle connectionHandle, boolean logStatementsEnabled)
          Constructor for empty statement (created via connection.createStatement)
StatementHandle(java.sql.Statement internalStatement, java.lang.String sql, IStatementCache cache, ConnectionHandle connectionHandle, java.lang.String cacheKey, boolean logStatementsEnabled)
          Constructor to statement handle wrapper.
 
Method Summary
 void addBatch(java.lang.String sql)
          
 void cancel()
          
 void clearBatch()
          
 void clearWarnings()
          
 void close()
           
 boolean execute(java.lang.String sql)
          
 boolean execute(java.lang.String sql, int autoGeneratedKeys)
          
 boolean execute(java.lang.String sql, int[] columnIndexes)
          
 boolean execute(java.lang.String sql, java.lang.String[] columnNames)
          
 int[] executeBatch()
          
 java.sql.ResultSet executeQuery(java.lang.String sql)
          
 int executeUpdate(java.lang.String sql)
          
 int executeUpdate(java.lang.String sql, int autoGeneratedKeys)
          
 int executeUpdate(java.lang.String sql, int[] columnIndexes)
          
 int executeUpdate(java.lang.String sql, java.lang.String[] columnNames)
          
 java.sql.Connection getConnection()
          
 java.lang.Object getDebugHandle()
          Returns the debugHandle field.
 int getFetchDirection()
          
 int getFetchSize()
          
 java.sql.ResultSet getGeneratedKeys()
          
 java.sql.Statement getInternalStatement()
          Returns the statement being wrapped around by this wrapper.
 int getMaxFieldSize()
          
 int getMaxRows()
          
 boolean getMoreResults()
          
 boolean getMoreResults(int current)
          
 java.lang.String getOpenStackTrace()
          Returns the stack trace where this statement was first opened.
 int getQueryTimeout()
          
 java.sql.ResultSet getResultSet()
          
 int getResultSetConcurrency()
          
 int getResultSetHoldability()
          
 int getResultSetType()
          
 int getUpdateCount()
          
 java.sql.SQLWarning getWarnings()
          
 boolean isClosed()
          Returns true if statement is logically closed
 boolean isPoolable()
           
 boolean isWrapperFor(java.lang.Class<?> iface)
           
 void setCursorName(java.lang.String name)
           
 void setDebugHandle(java.lang.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(java.sql.Statement internalStatement)
          Sets the internal statement used by this wrapper.
 void setMaxFieldSize(int max)
          
 void setMaxRows(int max)
          
 void setOpenStackTrace(java.lang.String openStackTrace)
          Sets the stack trace where this statement was first opened.
 void setPoolable(boolean poolable)
           
 void setQueryTimeout(int seconds)
          
 java.lang.String toString()
           
<T> T
unwrap(java.lang.Class<T> iface)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inCache

public volatile boolean inCache
If true, this statement is in the cache.


openStackTrace

public java.lang.String openStackTrace
Stack trace capture of where this statement was opened.

Constructor Detail

StatementHandle

public StatementHandle(java.sql.Statement internalStatement,
                       java.lang.String sql,
                       IStatementCache cache,
                       ConnectionHandle connectionHandle,
                       java.lang.String cacheKey,
                       boolean logStatementsEnabled)
Constructor to statement handle wrapper.

Parameters:
internalStatement - handle to actual statement instance.
sql - statement used for this handle.
cache - Cache handle
connectionHandle - Handle to the connection
cacheKey -
logStatementsEnabled - set to true to log statements.

StatementHandle

public StatementHandle(java.sql.Statement internalStatement,
                       ConnectionHandle connectionHandle,
                       boolean logStatementsEnabled)
Constructor for empty statement (created via connection.createStatement)

Parameters:
internalStatement - wrapper to statement
connectionHandle - Handle to the connection that this statement is tied to.
logStatementsEnabled - set to true to enable sql logging.
Method Detail

close

public void close()
           throws java.sql.SQLException
Specified by:
close in interface java.sql.Statement
Throws:
java.sql.SQLException

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException

Specified by:
addBatch in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.addBatch(java.lang.String)

cancel

public void cancel()
            throws java.sql.SQLException

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.cancel()

clearBatch

public void clearBatch()
                throws java.sql.SQLException

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.clearBatch()

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.clearWarnings()

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.execute(java.lang.String)

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.SQLException

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.execute(java.lang.String, int)

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.execute(java.lang.String, int[])

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException

Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.execute(java.lang.String, java.lang.String[])

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException

Specified by:
executeBatch in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeBatch()

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException

Specified by:
executeQuery in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeQuery(java.lang.String)

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeUpdate(java.lang.String)

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.SQLException

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeUpdate(java.lang.String, int)

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.SQLException

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeUpdate(java.lang.String, int[])

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.SQLException

Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.executeUpdate(java.lang.String, java.lang.String[])

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

Specified by:
getConnection in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getConnection()

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException

Specified by:
getFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getFetchDirection()

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException

Specified by:
getFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getFetchSize()

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException

Specified by:
getGeneratedKeys in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getGeneratedKeys()

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException

Specified by:
getMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getMaxFieldSize()

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException

Specified by:
getMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getMaxRows()

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException

Specified by:
getMoreResults in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getMoreResults()

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException

Specified by:
getMoreResults in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getMoreResults(int)

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException

Specified by:
getQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getQueryTimeout()

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException

Specified by:
getResultSet in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getResultSet()

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getResultSetConcurrency()

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException

Specified by:
getResultSetHoldability in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getResultSetHoldability()

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException

Specified by:
getResultSetType in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getResultSetType()

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException

Specified by:
getUpdateCount in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getUpdateCount()

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException

Specified by:
getWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getWarnings()

isClosed

public boolean isClosed()
Returns true if statement is logically closed

Specified by:
isClosed in interface java.sql.Statement
Returns:
True if handle is closed

setPoolable

public void setPoolable(boolean poolable)
                 throws java.sql.SQLException
Specified by:
setPoolable in interface java.sql.Statement
Throws:
java.sql.SQLException

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException
Specified by:
isWrapperFor in interface java.sql.Wrapper
Throws:
java.sql.SQLException

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException
Specified by:
unwrap in interface java.sql.Wrapper
Throws:
java.sql.SQLException

isPoolable

public boolean isPoolable()
                   throws java.sql.SQLException
Specified by:
isPoolable in interface java.sql.Statement
Throws:
java.sql.SQLException

setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Specified by:
setCursorName in interface java.sql.Statement
Throws:
java.sql.SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException

Specified by:
setEscapeProcessing in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setEscapeProcessing(boolean)

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException

Specified by:
setFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setFetchDirection(int)

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException

Specified by:
setFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setFetchSize(int)

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException

Specified by:
setMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setMaxFieldSize(int)

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException

Specified by:
setMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setMaxRows(int)

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException

Specified by:
setQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setQueryTimeout(int)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOpenStackTrace

public java.lang.String getOpenStackTrace()
Returns the stack trace where this statement was first opened.

Returns:
the openStackTrace

setOpenStackTrace

public void setOpenStackTrace(java.lang.String openStackTrace)
Sets the stack trace where this statement was first opened.

Parameters:
openStackTrace - the openStackTrace to set

getInternalStatement

public java.sql.Statement getInternalStatement()
Returns the statement being wrapped around by this wrapper.

Returns:
the internalStatement being used.

setInternalStatement

public void setInternalStatement(java.sql.Statement internalStatement)
Sets the internal statement used by this wrapper.

Parameters:
internalStatement - the internalStatement to set

setDebugHandle

public void setDebugHandle(java.lang.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.

Parameters:
debugHandle - any object.

getDebugHandle

public java.lang.Object getDebugHandle()
Returns the debugHandle field.

Returns:
debugHandle


Copyright © 2009-2011 JolBox. All Rights Reserved.