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
A wrapper for a connection.
- Version:
- $Revision: 96595 $
- Author:
- David Jencks, Adrian Brock, Jesper Pedersen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanDo lockingprotected StringThe jndi nameprotected booleanSpy functionalityprotected static org.jboss.logging.LoggerThe spy loggerFields inherited from class org.jboss.jca.adapters.jdbc.JBossWrapper
bundleFields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
ConstructorsConstructorDescriptionWrappedConnection(BaseWrapperManagedConnection mc, boolean spy, String jndiName, boolean doLocking, ClassLoaderPlugin classLoaderPlugin) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected SQLExceptionThe base checkException method rethrows the supplied exception, informing the ManagedConnection of the error.protected voidThe checkStatus method checks that the handle has not been closed and that it is associated with a managed connection.protected voidvoidvoidclose()voidcommit()createArrayOf(String typeName, Object[] elements) createStatement(int resultSetType, int resultSetConcurrency) createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct(String typeName, Object[] attributes) booleangetClientInfo(String name) Get the datasourceintintintprotected ConnectionGet the wrapped object - override in sub-classesReturns the XAResource if the connection is an XA based onevoidInvalidate a connectionbooleanisClosed()booleanbooleanisValid(int timeout) booleanisWrapperFor(Class<?> iface) Is a wrapper forbooleanisXA()Returns true if the underlying connection is handled by an XA resource managerprotected voidlock()Lock connectionprepareCall(String sql) prepareCall(String sql, int resultSetType, int resultSetConcurrency) prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement(String sql) prepareStatement(String sql, int autoGeneratedKeys) prepareStatement(String sql, int[] columnIndexes) prepareStatement(String sql, int resultSetType, int resultSetConcurrency) prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement(String sql, String[] columnNames) voidreleaseSavepoint(Savepoint savepoint) voidrollback()voidvoidsetAutoCommit(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) setSavepoint(String name) voidvoidsetTransactionIsolation(int isolationLevel) voidsetTypeMap(Map<String, Class<?>> typeMap) protected voidunlock()Unlock connection<T> TUnwrapprotected 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 statementMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
Field Details
-
spyLogger
protected static org.jboss.logging.Logger spyLoggerThe spy logger -
spy
protected boolean spySpy functionality -
jndiName
The jndi name -
doLocking
protected final boolean doLockingDo locking
-
-
Constructor Details
-
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 Details
-
lock
Lock connection- Throws:
SQLException- Thrown if an error occurs
-
unlock
protected void unlock()Unlock connection -
getDataSource
Get the datasource- Returns:
- The value
-
setDataSource
Set the datasource- Parameters:
dataSource- The value
-
setReadOnly
- Specified by:
setReadOnlyin interfaceConnection- Throws:
SQLException
-
isReadOnly
- Specified by:
isReadOnlyin interfaceConnection- Throws:
SQLException
-
invalidate
Invalidate a connection- Throws:
SQLException- if a database access error occurs
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException
-
isClosed
- 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
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
- 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
- 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
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- 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
- 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
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
commit
- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
getMetaData
- Specified by:
getMetaDatain interfaceConnection- Throws:
SQLException
-
setCatalog
- Specified by:
setCatalogin interfaceConnection- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalogin interfaceConnection- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getTransactionIsolation
- Specified by:
getTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getWarnings
- Specified by:
getWarningsin interfaceConnection- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarningsin interfaceConnection- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMapin interfaceConnection- Throws:
SQLException
-
setTypeMap
- Specified by:
setTypeMapin interfaceConnection- Throws:
SQLException
-
setHoldability
- Specified by:
setHoldabilityin interfaceConnection- Throws:
SQLException
-
getHoldability
- Specified by:
getHoldabilityin interfaceConnection- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepointin interfaceConnection- Throws:
SQLException
-
createArrayOf
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createBlob
- Specified by:
createBlobin interfaceConnection- Throws:
SQLException
-
createClob
- Specified by:
createClobin interfaceConnection- Throws:
SQLException
-
createNClob
- Specified by:
createNClobin interfaceConnection- Throws:
SQLException
-
createSQLXML
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
createStruct
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
getClientInfo
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
getClientInfo
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
isValid
- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
setSchema
- Specified by:
setSchemain interfaceConnection- Throws:
SQLException
-
getSchema
- Specified by:
getSchemain interfaceConnection- Throws:
SQLException
-
abort
- Specified by:
abortin interfaceConnection- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getNetworkTimeout
- Specified by:
getNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getUnderlyingConnection
- Throws:
SQLException
-
isXA
public boolean isXA()Returns true if the underlying connection is handled by an XA resource manager- Returns:
- The value
-
getXAResource
Returns the XAResource if the connection is an XA based one- Returns:
- The value
- Throws:
jakarta.resource.ResourceException- Thrown if it isn't an XA based connection
-
isWrapperFor
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
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
Get the wrapped object - override in sub-classes- Overrides:
getWrappedObjectin classJBossWrapper- Returns:
- The object
- Throws:
SQLException- Thrown if an error occurs
-
checkTransaction
- Throws:
SQLException
-
checkStatus
The 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
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
-