Package bitronix.tm.resource.jdbc
Class JdbcPooledConnection
java.lang.Object
bitronix.tm.resource.common.AbstractXAStatefulHolder
bitronix.tm.resource.common.AbstractXAResourceHolder
bitronix.tm.resource.jdbc.JdbcPooledConnection
- All Implemented Interfaces:
StateChangeListener,XAResourceHolder,XAStatefulHolder,JdbcPooledConnectionMBean
public class JdbcPooledConnection
extends AbstractXAResourceHolder
implements StateChangeListener, JdbcPooledConnectionMBean
Implementation of a JDBC pooled connection wrapping vendor's
XAConnection implementation.- Author:
- lorban, brettw
-
Field Summary
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE -
Constructor Summary
ConstructorsConstructorDescriptionJdbcPooledConnection(PoolingDataSource poolingDataSource, XAConnection xaConnection) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the physical connection that thisXAStatefulHolderrepresents.protected JdbcPreparedStatementHandleGet a PreparedStatement from cache.Create a disposable handler used to drive a pooled instance ofXAStatefulHolder.Get the date at which this object was last released to the pool.Get the ResourceBean which created this XAResourceHolder.Get the vendor'sXAResourceimplementation of the wrapped resource.Get the list ofXAResourceHolders created by thisXAStatefulHolderthat are still open.protected JdbcPreparedStatementHandlePut a PreparedStatement in the cache.protected StatementRegister uncached statement so that it can be closed when the connection is put back in the pool.protected voidrelease()voidstateChanged(XAStatefulHolder source, int oldState, int newState) Fired when the internal state of aXAStatefulHolderhas changed.voidstateChanging(XAStatefulHolder source, int currentState, int futureState) Fired before the internal state of aXAStatefulHolderhas changed.toString()protected voidMethods inherited from class bitronix.tm.resource.common.AbstractXAResourceHolder
getXAResourceHolderStateGtrids, getXAResourceHolderStatesForGtrid, hasStateForXAResource, isParticipatingInActiveGlobalTransaction, putXAResourceHolderState, removeXAResourceHolderStateMethods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
-
Constructor Details
-
JdbcPooledConnection
public JdbcPooledConnection(PoolingDataSource poolingDataSource, XAConnection xaConnection) throws SQLException - Throws:
SQLException
-
-
Method Details
-
close
Description copied from interface:XAStatefulHolderClose the physical connection that thisXAStatefulHolderrepresents.- Specified by:
closein interfaceXAStatefulHolder- Throws:
SQLException
-
createRecoveryXAResourceHolder
-
release
- Throws:
SQLException
-
getXAResource
Description copied from interface:XAResourceHolderGet the vendor'sXAResourceimplementation of the wrapped resource.- Specified by:
getXAResourcein interfaceXAResourceHolder- Returns:
- the vendor's XAResource implementation.
-
getResourceBean
Description copied from interface:XAResourceHolderGet the ResourceBean which created this XAResourceHolder.- Specified by:
getResourceBeanin interfaceXAResourceHolder- Returns:
- the ResourceBean which created this XAResourceHolder.
-
getPoolingDataSource
-
getXAResourceHolders
Description copied from interface:XAStatefulHolderGet the list ofXAResourceHolders created by thisXAStatefulHolderthat are still open.This method is thread-safe.
- Specified by:
getXAResourceHoldersin interfaceXAStatefulHolder- Returns:
- the list of
XAResourceHolders created by thisXAStatefulHolderthat are still open.
-
getConnectionHandle
Description copied from interface:XAStatefulHolderCreate a disposable handler used to drive a pooled instance ofXAStatefulHolder.This method is thread-safe.
- Specified by:
getConnectionHandlein interfaceXAStatefulHolder- Returns:
- a resource-specific disaposable connection object.
- Throws:
Exception- a resource-specific exception thrown when the disaposable connection cannot be created.
-
stateChanged
Description copied from interface:StateChangeListenerFired when the internal state of aXAStatefulHolderhas changed.- Specified by:
stateChangedin interfaceStateChangeListener- Parameters:
source- theXAStatefulHolderchanging state.oldState- the old state of theXAStatefulHolder.newState- the new state of theXAStatefulHolder.
-
stateChanging
Description copied from interface:StateChangeListenerFired before the internal state of aXAStatefulHolderhas changed.- Specified by:
stateChangingin interfaceStateChangeListener- Parameters:
source- theXAStatefulHolderchanging state.currentState- the current state of theXAStatefulHolder.futureState- the future state of theXAStatefulHolder.
-
getCachedStatement
Get a PreparedStatement from cache.- Parameters:
stmt- the key that has been used to cache the statement.- Returns:
- the cached statement corresponding to the key or null if no statement is cached under that key.
-
putCachedStatement
Put a PreparedStatement in the cache.- Parameters:
stmt- the statement to cache.- Returns:
- the cached statement.
-
registerUncachedStatement
Register uncached statement so that it can be closed when the connection is put back in the pool.- Parameters:
stmt- the statement to register.- Returns:
- the registered statement.
-
unregisterUncachedStatement
-
toString
-
getStateDescription
- Specified by:
getStateDescriptionin interfaceJdbcPooledConnectionMBean
-
getAcquisitionDate
- Specified by:
getAcquisitionDatein interfaceJdbcPooledConnectionMBean
-
getLastReleaseDate
Description copied from interface:XAStatefulHolderGet the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.- Specified by:
getLastReleaseDatein interfaceXAStatefulHolder- Returns:
- the date at which this object was last released to the pool or null if it never left the pool.
-
getTransactionGtridsCurrentlyHoldingThis
- Specified by:
getTransactionGtridsCurrentlyHoldingThisin interfaceJdbcPooledConnectionMBean
-
getXaConnection
-