Package org.jboss.jca.adapters.jdbc
Class WrappedStatement
- java.lang.Object
-
- org.jboss.jca.adapters.jdbc.JBossWrapper
-
- org.jboss.jca.adapters.jdbc.WrappedStatement
-
- All Implemented Interfaces:
Serializable,AutoCloseable,Statement,Wrapper,StatementAccess
- Direct Known Subclasses:
WrappedPreparedStatement,WrappedStatementJDK7,WrappedStatementJDK8
public abstract class WrappedStatement extends JBossWrapper implements Statement, StatementAccess
A wrapper for a statement.- Author:
- David Jencks, Adrian Brock, Jesper Pedersen
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static IntegerdefaultFetchSizeDefault fetch sizeprotected booleandoLockingDo lockingprotected StringjndiNameThe jndi nameprotected booleanspySpy functionalityprotected static org.jboss.logging.LoggerspyLoggerThe spy loggerprotected StringspyLoggingCategoryThe spy logging category-
Fields inherited from class org.jboss.jca.adapters.jdbc.JBossWrapper
bundle
-
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 Modifier Constructor Description WrappedStatement(WrappedConnection lc, Statement s, boolean spy, String jndiName, boolean doLocking)ConstructorprotectedWrappedStatement(WrappedConnection lc, Statement s, boolean spy, String jndiName, boolean doLocking, String spyLoggingCategory)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddBatch(String sql)voidcancel()protected voidcheckConfiguredQueryTimeout()Check configured query timeoutprotected SQLExceptioncheckException(Throwable t)Check exceptionprotected voidcheckState()Check stateprotected voidcheckTransaction()Check transactionprotected voidcheckTransactionActive()Check if transaction is activevoidclearBatch()voidclearWarnings()voidclose()voidcloseOnCompletion()protected voidcloseResultSets()Close result setsbooleanexecute(String sql)booleanexecute(String sql, int autoGeneratedKeys)booleanexecute(String sql, int[] columnIndexes)booleanexecute(String sql, String[] columnNames)int[]executeBatch()ResultSetexecuteQuery(String sql)intexecuteUpdate(String sql)intexecuteUpdate(String sql, int autoGeneratedKeys)intexecuteUpdate(String sql, int[] columnIndexes)intexecuteUpdate(String sql, String[] columnNames)ConnectiongetConnection()intgetFetchDirection()intgetFetchSize()ResultSetgetGeneratedKeys()intgetMaxFieldSize()intgetMaxRows()booleangetMoreResults()booleangetMoreResults(int current)intgetQueryTimeout()ResultSetgetResultSet()intgetResultSetConcurrency()intgetResultSetHoldability()intgetResultSetType()StatementgetUnderlyingStatement()Get the underlying statementintgetUpdateCount()SQLWarninggetWarnings()protected StatementgetWrappedObject()Get the wrapped statementprotected voidinternalClose()ClosebooleanisClosed()booleanisCloseOnCompletion()booleanisPoolable()protected voidlock()Lock connectionprotected ResultSetregisterResultSet(ResultSet resultSet)Register a result setvoidsetCursorName(String name)voidsetEscapeProcessing(boolean enable)voidsetFetchDirection(int direction)voidsetFetchSize(int rows)voidsetMaxFieldSize(int max)voidsetMaxRows(int max)voidsetPoolable(boolean poolable)voidsetQueryTimeout(int timeout)protected voidunlock()Unlock connectionprotected voidunregisterResultSet(WrappedResultSet resultSet)Unregister a result setprotected abstract WrappedResultSetwrapResultSet(ResultSet resultSet, boolean spy, String jndiName, boolean doLocking)Wrap the result set-
Methods inherited from class org.jboss.jca.adapters.jdbc.JBossWrapper
isWrapperFor, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, getLargeUpdateCount, isSimpleIdentifier, setLargeMaxRows
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Field Detail
-
spyLogger
protected static org.jboss.logging.Logger spyLogger
The spy logger
-
spy
protected final boolean spy
Spy functionality
-
jndiName
protected final String jndiName
The jndi name
-
spyLoggingCategory
protected final String spyLoggingCategory
The spy logging category
-
defaultFetchSize
protected static Integer defaultFetchSize
Default fetch size
-
doLocking
protected final boolean doLocking
Do locking
-
-
Constructor Detail
-
WrappedStatement
public WrappedStatement(WrappedConnection lc, Statement s, boolean spy, String jndiName, boolean doLocking)
Constructor- Parameters:
lc- The connections- The statementspy- The spy valuejndiName- The jndi namedoLocking- Do locking
-
WrappedStatement
protected WrappedStatement(WrappedConnection lc, Statement s, boolean spy, String jndiName, boolean doLocking, String spyLoggingCategory)
Constructor- Parameters:
lc- The connections- The statementspy- The spy valuejndiName- The jndi namedoLocking- Do lockingspyLoggingCategory- The spy logging category
-
-
Method Detail
-
lock
protected void lock() throws SQLExceptionLock connection- Throws:
SQLException- Thrown if an error occurs
-
unlock
protected void unlock()
Unlock connection
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
public boolean execute(String sql, String[] columnNames) throws SQLException
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnectionin interfaceStatement- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarningsin interfaceStatement- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery(String sql) throws SQLException
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
public int executeUpdate(String sql, String[] columnNames) throws SQLException
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
getMaxFieldSize
public int getMaxFieldSize() throws SQLException- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws SQLException- Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
public int getMaxRows() throws SQLException- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
setMaxRows
public void setMaxRows(int max) throws SQLException- Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException- Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLException
-
getQueryTimeout
public int getQueryTimeout() throws SQLException- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
setQueryTimeout
public void setQueryTimeout(int timeout) throws SQLException- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLException
-
cancel
public void cancel() throws SQLException- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
setCursorName
public void setCursorName(String name) throws SQLException
- Specified by:
setCursorNamein interfaceStatement- Throws:
SQLException
-
getResultSet
public ResultSet getResultSet() throws SQLException
- Specified by:
getResultSetin interfaceStatement- Throws:
SQLException
-
getUpdateCount
public int getUpdateCount() throws SQLException- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults() throws SQLException- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws SQLException- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws SQLException- Specified by:
setFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchDirection
public int getFetchDirection() throws SQLException- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
setFetchSize
public void setFetchSize(int rows) throws SQLException- Specified by:
setFetchSizein interfaceStatement- Throws:
SQLException
-
getFetchSize
public int getFetchSize() throws SQLException- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws SQLException- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
getResultSetType
public int getResultSetType() throws SQLException- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLException
-
addBatch
public void addBatch(String sql) throws SQLException
- Specified by:
addBatchin interfaceStatement- Throws:
SQLException
-
clearBatch
public void clearBatch() throws SQLException- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException
-
executeBatch
public int[] executeBatch() throws SQLException- Specified by:
executeBatchin interfaceStatement- Throws:
SQLException
-
getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException
- Specified by:
getGeneratedKeysin interfaceStatement- Throws:
SQLException
-
getResultSetHoldability
public int getResultSetHoldability() throws SQLException- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException- Specified by:
isClosedin interfaceStatement- Throws:
SQLException
-
isPoolable
public boolean isPoolable() throws SQLException- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
setPoolable
public void setPoolable(boolean poolable) throws SQLException- Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
closeOnCompletion
public void closeOnCompletion() throws SQLException- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws SQLException- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
getUnderlyingStatement
public Statement getUnderlyingStatement() throws SQLException
Get the underlying statement- Specified by:
getUnderlyingStatementin interfaceStatementAccess- Returns:
- the underlying statement
- Throws:
SQLException- when already closed
-
getWrappedObject
protected Statement getWrappedObject() throws SQLException
Get the wrapped statement- Overrides:
getWrappedObjectin classJBossWrapper- Returns:
- The result
- Throws:
SQLException- Thrown if an error occurs
-
checkException
protected SQLException checkException(Throwable t) throws SQLException
Check exception- Parameters:
t- The throwable- Returns:
- The result
- Throws:
SQLException- Thrown if an error occurs
-
checkTransaction
protected void checkTransaction() throws SQLExceptionCheck transaction- Throws:
SQLException- Thrown if an error occurs
-
checkConfiguredQueryTimeout
protected void checkConfiguredQueryTimeout() throws SQLExceptionCheck configured query timeout- Throws:
SQLException- Thrown if an error occurs
-
checkTransactionActive
protected void checkTransactionActive() throws SQLExceptionCheck if transaction is active- Throws:
SQLException- Thrown if an error occurs
-
internalClose
protected void internalClose() throws SQLExceptionClose- Throws:
SQLException- Thrown if an error occurs
-
checkState
protected void checkState() throws SQLExceptionCheck state- Throws:
SQLException- Thrown if an error occurs
-
wrapResultSet
protected abstract WrappedResultSet wrapResultSet(ResultSet resultSet, boolean spy, String jndiName, boolean doLocking)
Wrap the result set- Parameters:
resultSet- The result setspy- The spy valuejndiName- The jndi namedoLocking- Do locking- Returns:
- The result
-
registerResultSet
protected ResultSet registerResultSet(ResultSet resultSet)
Register a result set- Parameters:
resultSet- The result set- Returns:
- The result
-
unregisterResultSet
protected void unregisterResultSet(WrappedResultSet resultSet)
Unregister a result set- Parameters:
resultSet- The result set
-
closeResultSets
protected void closeResultSets()
Close result sets
-
-