Class FBManagedConnection
- java.lang.Object
- 
- org.firebirdsql.jaybird.xca.FBManagedConnection
 
- 
- All Implemented Interfaces:
- ExceptionListener
 
 public final class FBManagedConnection extends java.lang.Object implements ExceptionListener A physical connection handle to a Firebird database, providing aXAResource.- Author:
- David Jencks, Mark Rotteveel
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringERROR_NO_CHARSET
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConnectionEventListener(XcaConnectionEventListener listener)Add anXcaConnectionEventListenerlistener.voidcleanup()Application server calls this method to force any cleanup on the managed connection instance.voidclose(FBConnection c)Close this connection with regard to a wrappingAbstractConnection.voiddestroy()Destroys the physical connection to the underlying resource manager.voiddestroy(XcaConnectionEvent connectionEvent)voiderrorOccurred(java.lang.Object source, java.sql.SQLException ex)Notify about a SQLExceptionFBConnectiongetConnection()Creates a new connection handle for the underlying physical connection represented by the managed connection instance.FBConnectionRequestInfogetConnectionRequestInfo()Get information about the current connection parameters.java.lang.StringgetDatabase()Deprecated.Will be removed in Jaybird 6; there is no direction replacementGDSHelpergetGDSHelper()Get instance ofGDSHelperconnected with this managed connection.FBLocalTransactiongetLocalTransaction()Returns aFBLocalTransactioninstance.FBManagedConnectionFactorygetManagedConnectionFactory()Get the managed connection factory that created this managed connection.intgetTransactionIsolation()Get the transaction isolation level of this connection.TransactionParameterBuffergetTransactionParameters()TransactionParameterBuffergetTransactionParameters(int isolation)javax.transaction.xa.XAResourcegetXAResource()Returns anjavax.transaction.xa.XAResourceinstance.booleaninDistributedTransaction()voidinternalStart(javax.transaction.xa.Xid id, int flags)Perform the internal processing to start associate a JDBC connection with a global transaction.booleaninTransaction()booleanisLockedByCurrentThread()booleanisManagedEnvironment()booleanisReadOnly()Retrieve whether this connection is readonly.voidremoveConnectionEventListener(XcaConnectionEventListener listener)Remove aXcaConnectionEventListenerfrom the listing of listeners that will be notified for aXcaConnectionEvent.voidsetManagedEnvironment(boolean managedEnvironment)voidsetReadOnly(boolean readOnly)Set whether this connection is to be readonlyvoidsetTransactionIsolation(int isolation)Set the transaction level for this connection.voidsetTransactionParameters(int isolation, TransactionParameterBuffer transactionParams)voidsetTransactionParameters(TransactionParameterBuffer transactionParameters)LockCloseablewithLock()
 
- 
- 
- 
Field Detail- 
ERROR_NO_CHARSETpublic static final java.lang.String ERROR_NO_CHARSET - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
errorOccurredpublic void errorOccurred(java.lang.Object source, java.sql.SQLException ex)Description copied from interface:ExceptionListenerNotify about a SQLException- Specified by:
- errorOccurredin interface- ExceptionListener
- Parameters:
- source- The source of the event; note for caller: this should be the object this listener is registered at.
- ex- error that occurred.
 
 - 
getGDSHelperpublic GDSHelper getGDSHelper() throws java.sql.SQLException Get instance ofGDSHelperconnected with this managed connection.- Returns:
- instance of GDSHelper.
- Throws:
- java.sql.SQLException- If this connection has no GDSHelper
 
 - 
getDatabase@Deprecated public java.lang.String getDatabase() Deprecated.Will be removed in Jaybird 6; there is no direction replacementReturns thedatabaseNameproperty as configured on theManagedConnectionFactory.- Returns:
- database name
 
 - 
isManagedEnvironmentpublic boolean isManagedEnvironment() 
 - 
inTransactionpublic boolean inTransaction() 
 - 
setManagedEnvironmentpublic void setManagedEnvironment(boolean managedEnvironment) throws java.sql.SQLException- Throws:
- java.sql.SQLException
 
 - 
getLocalTransactionpublic FBLocalTransaction getLocalTransaction() Returns aFBLocalTransactioninstance.The FBLocalTransaction is used by the container to manage local transactions for a RM instance. - Returns:
- FBLocalTransaction instance
 
 - 
addConnectionEventListenerpublic void addConnectionEventListener(XcaConnectionEventListener listener) Add anXcaConnectionEventListenerlistener. The listener will be notified when aXcaConnectionEventoccurs.- Parameters:
- listener- The- XcaConnectionEventListenerto be added
 
 - 
removeConnectionEventListenerpublic void removeConnectionEventListener(XcaConnectionEventListener listener) Remove aXcaConnectionEventListenerfrom the listing of listeners that will be notified for aXcaConnectionEvent.- Parameters:
- listener- The- FirebirdConnectionEventListenerto be removed
 
 - 
cleanuppublic void cleanup() throws java.sql.SQLExceptionApplication server calls this method to force any cleanup on the managed connection instance.The method cleanupinitiates a cleanup of the any client-specific state as maintained by a managed connection instance. The cleanup should invalidate all connection handles that had been created using this managed connection instance. Any attempt by an application component to use the connection handle after cleanup of the underlying managed connection should result in an exception.The cleanup of managed connection is always driven by an application server. An application server should not invoke cleanupwhen there is an uncompleted transaction (associated with a managed connection instance) in progress.The invocation of the cleanupmethod on an already cleaned-up connection should not throw an exception.The cleanup of a managed connection instance resets its client specific state and prepares the connection to be put back in to a connection pool. The cleanup method should not cause resource adapter to close the physical pipe and reclaim system resources associated with the physical connection. - Throws:
- java.sql.SQLException- generic exception if operation fails
 
 - 
getConnectionpublic FBConnection getConnection() throws java.sql.SQLException Creates a new connection handle for the underlying physical connection represented by the managed connection instance. This connection handle is used by the application code to refer to the underlying physical connection.- Returns:
- instance representing the connection handle
- Throws:
- java.sql.SQLException- generic exception if operation fails
 
 - 
destroypublic void destroy() throws java.sql.SQLExceptionDestroys the physical connection to the underlying resource manager.To manage the size of the connection pool, an application server can explicitly call destroyto destroy a physical connection. A resource adapter should destroy all allocated system resources for this managed connection instance when the method destroy is called.- Throws:
- java.sql.SQLException- generic exception if operation failed
 
 - 
destroypublic void destroy(XcaConnectionEvent connectionEvent) throws java.sql.SQLException - Throws:
- java.sql.SQLException
 
 - 
getXAResourcepublic javax.transaction.xa.XAResource getXAResource() Returns anjavax.transaction.xa.XAResourceinstance. An application server enlists this XAResource instance with the Transaction Manager if the FBManagedConnection instance is being used in a Java EE transaction that is coordinated by the Transaction Manager.- Returns:
- XAResource instance
 
 - 
withLockpublic LockCloseable withLock() - See Also:
- FbAttachment.withLock()
 
 - 
isLockedByCurrentThreadpublic boolean isLockedByCurrentThread() - See Also:
- FbAttachment.isLockedByCurrentThread()
 
 - 
inDistributedTransactionpublic boolean inDistributedTransaction() 
 - 
internalStartpublic void internalStart(javax.transaction.xa.Xid id, int flags) throws javax.transaction.xa.XAException, java.sql.SQLExceptionPerform the internal processing to start associate a JDBC connection with a global transaction.- Parameters:
- id- A global transaction identifier to be associated with the resource
- flags- One of TMNOFLAGS, TMJOIN, or TMRESUME
- Throws:
- javax.transaction.xa.XAException- If the transaction is already started, or this connection cannot participate in the distributed transaction
- java.sql.SQLException
- See Also:
- start(Xid, int)
 
 - 
closepublic void close(FBConnection c) Close this connection with regard to a wrappingAbstractConnection.- Parameters:
- c- The- AbstractConnectionthat is being closed
 
 - 
getConnectionRequestInfopublic FBConnectionRequestInfo getConnectionRequestInfo() Get information about the current connection parameters.- Returns:
- instance of FBConnectionRequestInfo.
 
 - 
getTransactionParameterspublic TransactionParameterBuffer getTransactionParameters() 
 - 
setTransactionParameterspublic void setTransactionParameters(TransactionParameterBuffer transactionParameters) 
 - 
getTransactionParameterspublic TransactionParameterBuffer getTransactionParameters(int isolation) 
 - 
setTransactionParameterspublic void setTransactionParameters(int isolation, TransactionParameterBuffer transactionParams) throws java.sql.SQLException- Throws:
- java.sql.SQLException
 
 - 
getTransactionIsolationpublic int getTransactionIsolation() throws java.sql.SQLExceptionGet the transaction isolation level of this connection. The level is one of the static final fields ofjava.sql.Connection(i.e.TRANSACTION_READ_COMMITTED,TRANSACTION_READ_UNCOMMITTED,TRANSACTION_REPEATABLE_READ,TRANSACTION_SERIALIZABLE.- Returns:
- Value representing a transaction isolation level defined in Connection.
- Throws:
- java.sql.SQLException- If the transaction level cannot be retrieved
- See Also:
- Connection,- setTransactionIsolation(int)
 
 - 
setTransactionIsolationpublic void setTransactionIsolation(int isolation) throws java.sql.SQLExceptionSet the transaction level for this connection. The level is one of the static final fields ofjava.sql.Connection(i.e.TRANSACTION_READ_COMMITTED,TRANSACTION_READ_UNCOMMITTED,TRANSACTION_REPEATABLE_READ,TRANSACTION_SERIALIZABLE.- Parameters:
- isolation- Value representing a transaction isolation level defined in- Connection.
- Throws:
- java.sql.SQLException- If the transaction level cannot be retrieved
- See Also:
- Connection,- getTransactionIsolation()
 
 - 
getManagedConnectionFactorypublic FBManagedConnectionFactory getManagedConnectionFactory() Get the managed connection factory that created this managed connection.- Returns:
- instance of FBManagedConnectionFactory.
 
 - 
setReadOnlypublic void setReadOnly(boolean readOnly) Set whether this connection is to be readonly- Parameters:
- readOnly- If- true, the connection will be set read-only, otherwise it will be writable
 
 - 
isReadOnlypublic boolean isReadOnly() Retrieve whether this connection is readonly.- Returns:
- trueif this connection is readonly,- falseotherwise
 
 
- 
 
-