public class ManagedConnectionImpl extends Object implements javax.resource.spi.ManagedConnection, javax.resource.spi.LazyEnlistableManagedConnection, javax.resource.spi.DissociatableManagedConnection
ManagedConnection
implementation for Generic JDBC Connector.Modifier and Type | Field and Description |
---|---|
protected static Logger |
_logger |
protected Connection |
actualConnection |
protected javax.resource.spi.ConnectionEvent |
ce |
protected int |
connectionCount |
protected Hashtable |
connectionHandles |
protected int |
connectionType |
protected boolean |
initSqlExecuted |
static String |
IS_SLOW_SQL_LOGGING_DISABLED |
protected boolean |
isClean |
protected boolean |
isDestroyed |
static int |
ISNOTAPOOLEDCONNECTION |
static int |
ISPOOLEDCONNECTION |
protected boolean |
isUsable |
static int |
ISXACONNECTION |
protected int |
lastTransactionIsolationLevel |
protected StatementLeakDetector |
leakDetector |
protected javax.resource.spi.ConnectionEventListener |
listener |
protected static StringManager |
localStrings |
protected PrintWriter |
logWriter |
protected ConnectionHolder |
myLogicalConnection |
protected javax.resource.spi.security.PasswordCredential |
passwdCredential |
protected PooledConnection |
pc |
protected boolean |
transactionInProgress |
protected XAResource |
xar |
Constructor and Description |
---|
ManagedConnectionImpl(PooledConnection pooledConn,
Connection sqlConn,
javax.resource.spi.security.PasswordCredential passwdCred,
javax.resource.spi.ManagedConnectionFactory mcf,
PoolInfo poolInfo,
int statementCacheSize,
String statementCacheType,
SQLTraceDelegator delegator,
long statementLeakTimeout,
boolean statementLeakReclaim)
Constructor for
ManagedConnectionImpl . |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Adds a connection event listener to the ManagedConnectionImpl instance.
|
void |
associateConnection(Object connection)
Used by the container to change the association of an application-level
connection handle with a
ManagedConnectionImpl instance. |
void |
checkIfActive(ConnectionHolder ch)
This method is called by a Connection Handle to check if it is
the active Connection Handle.
|
void |
cleanup()
Application server calls this method to force any cleanup on the
ManagedConnectionImpl instance. |
void |
connectionClosed(Exception e,
ConnectionHolder connHolder30Object)
This method is called by the
ConnectionHolder30 when its close method is
called. |
void |
decrementCount() |
void |
destroy()
Destroys the physical connection to the underlying resource manager.
|
void |
dissociateConnections() |
DatabaseMetaData |
getCachedDatabaseMetaData()
Returns the cached
DatabaseMetaData . |
Object |
getConnection(Subject sub,
javax.resource.spi.ConnectionRequestInfo cxReqInfo)
Creates a new connection handle for the underlying physical
connection represented by the
ManagedConnectionImpl instance. |
protected int |
getConnectionType(PooledConnection pooledConn)
This method determines the type of the connection being held
in this
ManagedConnectionImpl . |
boolean |
getLastAutoCommitValue() |
StatementLeakDetector |
getLeakDetector() |
javax.resource.spi.LocalTransaction |
getLocalTransaction()
Returns an
LocalTransactionImpl instance. |
PrintWriter |
getLogWriter()
Gets the log writer for this
ManagedConnectionImpl instance. |
ManagedConnectionFactoryImpl |
getManagedConnectionFactory()
Returns the
ManagedConnectionFactory instance that
created this ManagedConnection instance. |
javax.resource.spi.ManagedConnectionFactory |
getMcf() |
javax.resource.spi.ManagedConnectionMetaData |
getMetaData()
Gets the metadata information for this connection's underlying EIS
resource manager instance.
|
int |
getStatementTimeout() |
XAResource |
getXAResource()
Returns an
XAResource instance. |
void |
incrementCount() |
void |
initializeConnectionType(int _connectionType)
sets the connection type of this connection.
|
protected void |
invalidateAllConnectionHandles()
This method removes all the connection handles from the table
of connection handles and invalidates all of them so that any
operation on those connection handles throws an exception.
|
boolean |
isAborted() |
Boolean |
isClientInfoSupported() |
boolean |
isTransactionInProgress()
Checks if a this ManagedConnection is involved in a transaction
or not.
|
void |
markForRemoval(boolean flag) |
CallableStatement |
prepareCachedCallableStatement(ConnectionWrapper conWrapper,
String sql,
int resultSetType,
int resultSetConcurrency) |
CallableStatement |
prepareCachedCallableStatement(ConnectionWrapper conWrapper,
String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
PreparedStatement |
prepareCachedStatement(ConnectionWrapper conWrapper,
String sql,
int autoGeneratedKeys) |
PreparedStatement |
prepareCachedStatement(ConnectionWrapper conWrapper,
String sql,
int[] columnIndexes) |
PreparedStatement |
prepareCachedStatement(ConnectionWrapper conWrapper,
String sql,
int resultSetType,
int resultSetConcurrency) |
PreparedStatement |
prepareCachedStatement(ConnectionWrapper conWrapper,
String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
PreparedStatement |
prepareCachedStatement(ConnectionWrapper conWrapper,
String sql,
String[] columnNames) |
void |
purgeStatementFromCache(PreparedStatement preparedStatement) |
void |
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Removes an already registered connection event listener from the
ManagedConnectionImpl instance. |
void |
setAborted(boolean flag) |
void |
setClientInfoSupported(Boolean isClientInfoSupported) |
void |
setLastAutoCommitValue(boolean lastAutoCommitValue)
To keep track of last auto commit value.
|
void |
setLastTransactionIsolationLevel(int isolationLevel) |
void |
setLogWriter(PrintWriter out)
Sets the log writer for this
ManagedConnectionImpl instance. |
public static final int ISNOTAPOOLEDCONNECTION
public static final int ISPOOLEDCONNECTION
public static final int ISXACONNECTION
protected boolean isDestroyed
protected boolean isUsable
protected boolean initSqlExecuted
protected int connectionCount
public static final String IS_SLOW_SQL_LOGGING_DISABLED
protected int connectionType
protected PooledConnection pc
protected Connection actualConnection
protected Hashtable connectionHandles
protected PrintWriter logWriter
protected javax.resource.spi.security.PasswordCredential passwdCredential
protected XAResource xar
protected ConnectionHolder myLogicalConnection
protected int lastTransactionIsolationLevel
protected boolean isClean
protected boolean transactionInProgress
protected javax.resource.spi.ConnectionEventListener listener
protected javax.resource.spi.ConnectionEvent ce
protected StatementLeakDetector leakDetector
protected static final Logger _logger
protected static final StringManager localStrings
public ManagedConnectionImpl(PooledConnection pooledConn, Connection sqlConn, javax.resource.spi.security.PasswordCredential passwdCred, javax.resource.spi.ManagedConnectionFactory mcf, PoolInfo poolInfo, int statementCacheSize, String statementCacheType, SQLTraceDelegator delegator, long statementLeakTimeout, boolean statementLeakReclaim) throws javax.resource.ResourceException
ManagedConnectionImpl
. The pooledConn parameter is expected
to be null and sqlConn parameter is the actual connection in case where
the actual connection is got from a non pooled datasource object. The
pooledConn parameter is expected to be non null and sqlConn parameter
is expected to be null in the case where the datasource object is a
connection pool datasource or an xa datasource.pooledConn
- PooledConnection
object in case the
physical connection is to be obtained from a pooled
DataSource
; null otherwisesqlConn
- java.sql.Connection
object in case the physical
connection is to be obtained from a non pooled DataSource
;
null otherwisepasswdCred
- object conatining the
user and password for allocating the connectionjavax.resource.ResourceException
- if the ManagedConnectionFactory
object
that created this ManagedConnectionImpl
object
is not the same as returned by PasswordCredential
object passedpublic StatementLeakDetector getLeakDetector()
public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
addConnectionEventListener
in interface javax.resource.spi.ManagedConnection
listener
- ConnectionEventListener
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
public void associateConnection(Object connection) throws javax.resource.ResourceException
ManagedConnectionImpl
instance.associateConnection
in interface javax.resource.spi.ManagedConnection
connection
- ConnectionHolder30
to be associated with
this ManagedConnectionImpl
instancejavax.resource.ResourceException
- if the physical connection is no more
valid or the connection handle passed is nullpublic void cleanup() throws javax.resource.ResourceException
ManagedConnectionImpl
instance. This method calls the invalidate
method on all ConnectionHandles associated with this ManagedConnectionImpl
.cleanup
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
- if the physical connection is no more validprotected void invalidateAllConnectionHandles() throws javax.resource.ResourceException
javax.resource.ResourceException
- if there is a problem in retrieving
the connection handlespublic void destroy() throws javax.resource.ResourceException
destroy
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
- if there is an error in closing the physical connectionpublic Object getConnection(Subject sub, javax.resource.spi.ConnectionRequestInfo cxReqInfo) throws javax.resource.ResourceException
ManagedConnectionImpl
instance.getConnection
in interface javax.resource.spi.ManagedConnection
sub
- Subject
parameter needed for authenticationcxReqInfo
- ConnectionRequestInfo
carries the user
and password required for getting this connection.Object
javax.resource.ResourceException
- if there is an error in allocating the
physical connection from the pooled connectionjavax.resource.spi.SecurityException
- if there is a mismatch between the
password credentials or reauthentication is requestedpublic javax.resource.spi.LocalTransaction getLocalTransaction() throws javax.resource.ResourceException
LocalTransactionImpl
instance. The LocalTransactionImpl
interface
is used by the container to manage local transactions for a RM instance.getLocalTransaction
in interface javax.resource.spi.ManagedConnection
LocalTransactionImpl
instancejavax.resource.ResourceException
- if the physical connection is not validpublic PrintWriter getLogWriter() throws javax.resource.ResourceException
ManagedConnectionImpl
instance.getLogWriter
in interface javax.resource.spi.ManagedConnection
PrintWriter
instance associated with this
ManagedConnectionImpl
instancejavax.resource.ResourceException
- if the physical connection is not validsetLogWriter
public javax.resource.spi.ManagedConnectionMetaData getMetaData() throws javax.resource.ResourceException
getMetaData
in interface javax.resource.spi.ManagedConnection
ManagedConnectionMetaData
instancejavax.resource.ResourceException
- if the physical connection is not validpublic XAResource getXAResource() throws javax.resource.ResourceException
XAResource
instance.getXAResource
in interface javax.resource.spi.ManagedConnection
XAResource
instancejavax.resource.ResourceException
- if the physical connection is not valid or
there is an error in allocating the
XAResource
instancejavax.resource.NotSupportedException
- if underlying datasource is not an
XADataSource
public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
ManagedConnectionImpl
instance.removeConnectionEventListener
in interface javax.resource.spi.ManagedConnection
listener
- ConnectionEventListener
to be removedaddConnectionEventListener(javax.resource.spi.ConnectionEventListener)
public boolean isTransactionInProgress()
public void setLogWriter(PrintWriter out) throws javax.resource.ResourceException
ManagedConnectionImpl
instance.setLogWriter
in interface javax.resource.spi.ManagedConnection
out
- PrintWriter
to be associated with this
ManagedConnectionImpl
instancejavax.resource.ResourceException
- if the physical connection is not validgetLogWriter
protected int getConnectionType(PooledConnection pooledConn)
ManagedConnectionImpl
.pooledConn
- PooledConnection
public ManagedConnectionFactoryImpl getManagedConnectionFactory()
ManagedConnectionFactory
instance that
created this ManagedConnection
instance.ManagedConnectionFactory
instance that created this
ManagedConnection
instancepublic void connectionClosed(Exception e, ConnectionHolder connHolder30Object) throws SQLException
ConnectionHolder30
when its close method is
called. This ManagedConnection
instance invalidates the connection handle
and sends a CONNECTION_CLOSED event to all the registered event listeners.e
- Exception that may have occured while closing the connection handleconnHolder30Object
- ConnectionHolder30
that has been closedSQLException
- in case closing the sql connection got out of
getConnection
on the underlying
PooledConnection
throws an exceptionpublic void checkIfActive(ConnectionHolder ch) throws SQLException
ch
- ConnectionHolder30
that requests this
ManagedConnection
instance whether
it can be active or notSQLException
- in case the physical is not valid or
there is already an active connection handlepublic void initializeConnectionType(int _connectionType)
public void incrementCount()
public void decrementCount()
public void dissociateConnections()
dissociateConnections
in interface javax.resource.spi.DissociatableManagedConnection
public boolean getLastAutoCommitValue()
public void setLastAutoCommitValue(boolean lastAutoCommitValue)
lastAutoCommitValue
- public void markForRemoval(boolean flag)
public javax.resource.spi.ManagedConnectionFactory getMcf()
public int getStatementTimeout()
public void setLastTransactionIsolationLevel(int isolationLevel)
public DatabaseMetaData getCachedDatabaseMetaData() throws javax.resource.ResourceException
DatabaseMetaData
.DatabaseMetaData
javax.resource.ResourceException
public Boolean isClientInfoSupported()
public void setClientInfoSupported(Boolean isClientInfoSupported)
public PreparedStatement prepareCachedStatement(ConnectionWrapper conWrapper, String sql, int resultSetType, int resultSetConcurrency) throws SQLException
SQLException
public PreparedStatement prepareCachedStatement(ConnectionWrapper conWrapper, String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
SQLException
public PreparedStatement prepareCachedStatement(ConnectionWrapper conWrapper, String sql, String[] columnNames) throws SQLException
SQLException
public PreparedStatement prepareCachedStatement(ConnectionWrapper conWrapper, String sql, int[] columnIndexes) throws SQLException
SQLException
public PreparedStatement prepareCachedStatement(ConnectionWrapper conWrapper, String sql, int autoGeneratedKeys) throws SQLException
SQLException
public CallableStatement prepareCachedCallableStatement(ConnectionWrapper conWrapper, String sql, int resultSetType, int resultSetConcurrency) throws SQLException
SQLException
public CallableStatement prepareCachedCallableStatement(ConnectionWrapper conWrapper, String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
SQLException
public void setAborted(boolean flag)
public boolean isAborted()
public void purgeStatementFromCache(PreparedStatement preparedStatement)
Copyright © 2019. All rights reserved.