Package org.jboss.jca.adapters.jdbc
Class WrappedConnection
- java.lang.Object
-
- org.jboss.jca.adapters.jdbc.JBossWrapper
-
- org.jboss.jca.adapters.jdbc.WrappedConnection
-
- All Implemented Interfaces:
Serializable,AutoCloseable,Connection,Wrapper
- Direct Known Subclasses:
WrappedConnectionJDK7,WrappedConnectionJDK8
public abstract class WrappedConnection extends JBossWrapper implements Connection
A wrapper for a connection.- Version:
- $Revision: 96595 $
- Author:
- David Jencks, Adrian Brock, Jesper Pedersen
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandoLockingDo lockingprotected StringjndiNameThe jndi nameprotected booleanspySpy functionalityprotected static org.jboss.logging.LoggerspyLoggerThe spy logger-
Fields inherited from class org.jboss.jca.adapters.jdbc.JBossWrapper
bundle
-
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
-
Constructor Summary
Constructors Constructor Description WrappedConnection(BaseWrapperManagedConnection mc, boolean spy, String jndiName, boolean doLocking, ClassLoaderPlugin classLoaderPlugin)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidabort(Executor executor)protected SQLExceptioncheckException(Throwable t)The base checkException method rethrows the supplied exception, informing the ManagedConnection of the error.protected voidcheckStatus()The checkStatus method checks that the handle has not been closed and that it is associated with a managed connection.protected voidcheckTransaction()voidclearWarnings()voidclose()voidcommit()ArraycreateArrayOf(String typeName, Object[] elements)BlobcreateBlob()ClobcreateClob()NClobcreateNClob()SQLXMLcreateSQLXML()StatementcreateStatement()StatementcreateStatement(int resultSetType, int resultSetConcurrency)StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)StructcreateStruct(String typeName, Object[] attributes)booleangetAutoCommit()StringgetCatalog()PropertiesgetClientInfo()StringgetClientInfo(String name)WrapperDataSourcegetDataSource()Get the datasourceintgetHoldability()DatabaseMetaDatagetMetaData()intgetNetworkTimeout()StringgetSchema()intgetTransactionIsolation()Map<String,Class<?>>getTypeMap()ConnectiongetUnderlyingConnection()SQLWarninggetWarnings()protected ConnectiongetWrappedObject()Get the wrapped object - override in sub-classesXAResourcegetXAResource()Returns the XAResource if the connection is an XA based onevoidinvalidate()Invalidate a connectionbooleanisClosed()booleanisReadOnly()booleanisValid(int timeout)booleanisWrapperFor(Class<?> iface)Is a wrapper forbooleanisXA()Returns true if the underlying connection is handled by an XA resource managerprotected voidlock()Lock connectionStringnativeSQL(String sql)CallableStatementprepareCall(String sql)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql)PreparedStatementprepareStatement(String sql, int autoGeneratedKeys)PreparedStatementprepareStatement(String sql, int[] columnIndexes)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql, String[] columnNames)voidreleaseSavepoint(Savepoint savepoint)voidrollback()voidrollback(Savepoint savepoint)voidsetAutoCommit(boolean autocommit)voidsetCatalog(String catalog)voidsetClientInfo(String name, String value)voidsetClientInfo(Properties properties)protected voidsetDataSource(WrapperDataSource dataSource)Set the datasourcevoidsetHoldability(int holdability)voidsetNetworkTimeout(Executor executor, int milliseconds)voidsetReadOnly(boolean readOnly)SavepointsetSavepoint()SavepointsetSavepoint(String name)voidsetSchema(String schema)voidsetTransactionIsolation(int isolationLevel)voidsetTypeMap(Map<String,Class<?>> typeMap)protected voidunlock()Unlock connection<T> Tunwrap(Class<T> iface)Unwrapprotected abstract WrappedCallableStatementwrapCallableStatement(CallableStatement statement, boolean spy, String jndiName, boolean doLocking)Wrap a callable statementprotected abstract WrappedPreparedStatementwrapPreparedStatement(PreparedStatement statement, boolean spy, String jndiName, boolean doLocking)Wrap a prepared statementprotected abstract WrappedStatementwrapStatement(Statement statement, boolean spy, String jndiName, boolean doLocking)Wrap statement-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
-
-
-
Field Detail
-
spyLogger
protected static org.jboss.logging.Logger spyLogger
The spy logger
-
spy
protected boolean spy
Spy functionality
-
jndiName
protected String jndiName
The jndi name
-
doLocking
protected final boolean doLocking
Do locking
-
-
Constructor Detail
-
WrappedConnection
public WrappedConnection(BaseWrapperManagedConnection mc, boolean spy, String jndiName, boolean doLocking, ClassLoaderPlugin classLoaderPlugin)
Constructor- Parameters:
mc- The managed connectionspy- The spy valuejndiName- The jndi namedoLocking- Do locking
-
-
Method Detail
-
lock
protected void lock() throws SQLExceptionLock connection- Throws:
SQLException- Thrown if an error occurs
-
unlock
protected void unlock()
Unlock connection
-
getDataSource
public WrapperDataSource getDataSource()
Get the datasource- Returns:
- The value
-
setDataSource
protected void setDataSource(WrapperDataSource dataSource)
Set the datasource- Parameters:
dataSource- The value
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException- Specified by:
setReadOnlyin interfaceConnection- Throws:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException- Specified by:
isReadOnlyin interfaceConnection- Throws:
SQLException
-
invalidate
public void invalidate() throws SQLExceptionInvalidate a connection- Throws:
SQLException- if a database access error occurs
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException- Specified by:
isClosedin interfaceConnection- Throws:
SQLException
-
wrapStatement
protected abstract WrappedStatement wrapStatement(Statement statement, boolean spy, String jndiName, boolean doLocking)
Wrap statement- Parameters:
statement- The statementspy- The spy valuejndiName- The jndi namedoLocking- Do locking- Returns:
- The wrapped statement
-
createStatement
public Statement createStatement() throws SQLException
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
wrapPreparedStatement
protected abstract WrappedPreparedStatement wrapPreparedStatement(PreparedStatement statement, boolean spy, String jndiName, boolean doLocking)
Wrap a prepared statement- Parameters:
statement- The statementspy- The spy valuejndiName- The jndi namedoLocking- Do locking- Returns:
- The wrapped prepared statement
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
wrapCallableStatement
protected abstract WrappedCallableStatement wrapCallableStatement(CallableStatement statement, boolean spy, String jndiName, boolean doLocking)
Wrap a callable statement- Parameters:
statement- The statementspy- The spy valuejndiName- The jndi namedoLocking- Do locking- Returns:
- The wrapped callable statement
-
prepareCall
public CallableStatement prepareCall(String sql) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
nativeSQL
public String nativeSQL(String sql) throws SQLException
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean autocommit) throws SQLException- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
commit
public void commit() throws SQLException- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
public void rollback() throws SQLException- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
getMetaData
public DatabaseMetaData getMetaData() throws SQLException
- Specified by:
getMetaDatain interfaceConnection- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
- Specified by:
setCatalogin interfaceConnection- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalogin interfaceConnection- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int isolationLevel) throws SQLException- Specified by:
setTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException- Specified by:
getTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarningsin interfaceConnection- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceConnection- Throws:
SQLException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws SQLException
- Specified by:
getTypeMapin interfaceConnection- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> typeMap) throws SQLException
- Specified by:
setTypeMapin interfaceConnection- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException- Specified by:
setHoldabilityin interfaceConnection- Throws:
SQLException
-
getHoldability
public int getHoldability() throws SQLException- Specified by:
getHoldabilityin interfaceConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepointin interfaceConnection- Throws:
SQLException
-
createArrayOf
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createBlob
public Blob createBlob() throws SQLException
- Specified by:
createBlobin interfaceConnection- Throws:
SQLException
-
createClob
public Clob createClob() throws SQLException
- Specified by:
createClobin interfaceConnection- Throws:
SQLException
-
createNClob
public NClob createNClob() throws SQLException
- Specified by:
createNClobin interfaceConnection- Throws:
SQLException
-
createSQLXML
public SQLXML createSQLXML() throws SQLException
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
createStruct
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
setSchema
public void setSchema(String schema) throws SQLException
- Specified by:
setSchemain interfaceConnection- Throws:
SQLException
-
getSchema
public String getSchema() throws SQLException
- Specified by:
getSchemain interfaceConnection- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abortin interfaceConnection- Throws:
SQLException
-
setNetworkTimeout
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- Specified by:
setNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws SQLException- Specified by:
getNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getUnderlyingConnection
public Connection getUnderlyingConnection() throws SQLException
- Throws:
SQLException
-
isXA
public boolean isXA()
Returns true if the underlying connection is handled by an XA resource manager- Returns:
- The value
-
getXAResource
public XAResource getXAResource() throws javax.resource.ResourceException
Returns the XAResource if the connection is an XA based one- Returns:
- The value
- Throws:
javax.resource.ResourceException- Thrown if it isn't an XA based connection
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
Description copied from class:JBossWrapperIs a wrapper for- Specified by:
isWrapperForin interfaceWrapper- Overrides:
isWrapperForin classJBossWrapper- Parameters:
iface- The interface- Returns:
- True if wrapper; false otherwise
- Throws:
SQLException- Thrown if an error occurs
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
Description copied from class:JBossWrapperUnwrap- Specified by:
unwrapin interfaceWrapper- Overrides:
unwrapin classJBossWrapper- Type Parameters:
T- the type- Parameters:
iface- The interface- Returns:
- The object
- Throws:
SQLException- Thrown if an error occurs
-
getWrappedObject
protected Connection getWrappedObject() throws SQLException
Get the wrapped object - override in sub-classes- Overrides:
getWrappedObjectin classJBossWrapper- Returns:
- The object
- Throws:
SQLException- Thrown if an error occurs
-
checkTransaction
protected void checkTransaction() throws SQLException- Throws:
SQLException
-
checkStatus
protected void checkStatus() throws SQLExceptionThe checkStatus method checks that the handle has not been closed and that it is associated with a managed connection.- Throws:
SQLException- if an error occurs
-
checkException
protected SQLException checkException(Throwable t) throws SQLException
The base checkException method rethrows the supplied exception, informing the ManagedConnection of the error. Subclasses may override this to filter exceptions based on their severity.- Parameters:
t- a throwable- Returns:
- the sql exception
- Throws:
SQLException- if an error occurs
-
-