public final class FBManagedConnection extends java.lang.Object implements ExceptionListener
XAResource
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ERROR_NO_CHARSET |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionEventListener(XcaConnectionEventListener listener)
Add an
XcaConnectionEventListener listener. |
void |
cleanup()
Application server calls this method to force any cleanup on the managed connection instance.
|
void |
close(FBConnection c)
Close this connection with regard to a wrapping
AbstractConnection . |
void |
destroy()
Destroys the physical connection to the underlying resource manager.
|
void |
destroy(XcaConnectionEvent connectionEvent) |
void |
errorOccurred(java.lang.Object source,
java.sql.SQLException ex)
Notify about a SQLException
|
FBConnection |
getConnection()
Creates a new connection handle for the underlying physical connection represented by the managed connection
instance.
|
FBConnectionRequestInfo |
getConnectionRequestInfo()
Get information about the current connection parameters.
|
java.lang.String |
getDatabase()
Deprecated.
Will be removed in Jaybird 6; there is no direction replacement
|
GDSHelper |
getGDSHelper()
Get instance of
GDSHelper connected with this managed connection. |
FBLocalTransaction |
getLocalTransaction()
Returns a
FBLocalTransaction instance. |
FBManagedConnectionFactory |
getManagedConnectionFactory()
Get the managed connection factory that created this managed connection.
|
int |
getTransactionIsolation()
Get the transaction isolation level of this connection.
|
TransactionParameterBuffer |
getTransactionParameters() |
TransactionParameterBuffer |
getTransactionParameters(int isolation) |
javax.transaction.xa.XAResource |
getXAResource()
Returns an
javax.transaction.xa.XAResource instance. |
boolean |
inDistributedTransaction() |
void |
internalStart(javax.transaction.xa.Xid id,
int flags)
Perform the internal processing to start associate a JDBC connection with
a global transaction.
|
boolean |
inTransaction() |
boolean |
isLockedByCurrentThread() |
boolean |
isManagedEnvironment() |
boolean |
isReadOnly()
Retrieve whether this connection is readonly.
|
void |
removeConnectionEventListener(XcaConnectionEventListener listener)
Remove a
XcaConnectionEventListener from the listing of listeners that will be notified for a
XcaConnectionEvent . |
void |
setManagedEnvironment(boolean managedEnvironment) |
void |
setReadOnly(boolean readOnly)
Set whether this connection is to be readonly
|
void |
setTransactionIsolation(int isolation)
Set the transaction level for this connection.
|
void |
setTransactionParameters(int isolation,
TransactionParameterBuffer transactionParams) |
void |
setTransactionParameters(TransactionParameterBuffer transactionParameters) |
LockCloseable |
withLock() |
public static final java.lang.String ERROR_NO_CHARSET
public void errorOccurred(java.lang.Object source, java.sql.SQLException ex)
ExceptionListener
errorOccurred
in interface ExceptionListener
source
- The source of the event; note for caller: this should be the object this listener is registered at.ex
- error that occurred.public GDSHelper getGDSHelper() throws java.sql.SQLException
GDSHelper
connected with this managed connection.GDSHelper
.java.sql.SQLException
- If this connection has no GDSHelper@Deprecated public java.lang.String getDatabase()
databaseName
property as configured on the ManagedConnectionFactory
.public boolean isManagedEnvironment()
public boolean inTransaction()
public void setManagedEnvironment(boolean managedEnvironment) throws java.sql.SQLException
java.sql.SQLException
public FBLocalTransaction getLocalTransaction()
FBLocalTransaction
instance.
The FBLocalTransaction is used by the container to manage local transactions for a RM instance.
public void addConnectionEventListener(XcaConnectionEventListener listener)
XcaConnectionEventListener
listener. The listener will be notified when a
XcaConnectionEvent
occurs.listener
- The XcaConnectionEventListener
to be addedpublic void removeConnectionEventListener(XcaConnectionEventListener listener)
XcaConnectionEventListener
from the listing of listeners that will be notified for a
XcaConnectionEvent
.listener
- The FirebirdConnectionEventListener
to be removedpublic void cleanup() throws java.sql.SQLException
The method cleanup
initiates 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 cleanup
when there is an uncompleted transaction (associated with a managed connection instance)
in progress.
The invocation of the cleanup
method 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.
java.sql.SQLException
- generic exception if operation failspublic FBConnection getConnection() throws java.sql.SQLException
java.sql.SQLException
- generic exception if operation failspublic void destroy() throws java.sql.SQLException
To manage the size of the connection pool, an application server can explicitly call destroy
to destroy
a physical connection. A resource adapter should destroy all allocated system resources for this managed
connection instance when the method destroy is called.
java.sql.SQLException
- generic exception if operation failedpublic void destroy(XcaConnectionEvent connectionEvent) throws java.sql.SQLException
java.sql.SQLException
public javax.transaction.xa.XAResource getXAResource()
javax.transaction.xa.XAResource
instance. 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.public LockCloseable withLock()
FbAttachment.withLock()
public boolean isLockedByCurrentThread()
FbAttachment.isLockedByCurrentThread()
public boolean inDistributedTransaction()
public void internalStart(javax.transaction.xa.Xid id, int flags) throws javax.transaction.xa.XAException, java.sql.SQLException
id
- A global transaction identifier to be associated with the resourceflags
- One of TMNOFLAGS, TMJOIN, or TMRESUMEjavax.transaction.xa.XAException
- If the transaction is already started, or this connection cannot participate in the distributed
transactionjava.sql.SQLException
start(Xid, int)
public void close(FBConnection c)
AbstractConnection
.c
- The AbstractConnection
that is being closedpublic FBConnectionRequestInfo getConnectionRequestInfo()
FBConnectionRequestInfo
.public TransactionParameterBuffer getTransactionParameters()
public void setTransactionParameters(TransactionParameterBuffer transactionParameters)
public TransactionParameterBuffer getTransactionParameters(int isolation)
public void setTransactionParameters(int isolation, TransactionParameterBuffer transactionParams) throws java.sql.SQLException
java.sql.SQLException
public int getTransactionIsolation() throws java.sql.SQLException
java.sql.Connection
(i.e. TRANSACTION_READ_COMMITTED
, TRANSACTION_READ_UNCOMMITTED
,
TRANSACTION_REPEATABLE_READ
, TRANSACTION_SERIALIZABLE
.Connection
.java.sql.SQLException
- If the transaction level cannot be retrievedConnection
,
setTransactionIsolation(int)
public void setTransactionIsolation(int isolation) throws java.sql.SQLException
java.sql.Connection
(i.e. TRANSACTION_READ_COMMITTED
, TRANSACTION_READ_UNCOMMITTED
,
TRANSACTION_REPEATABLE_READ
, TRANSACTION_SERIALIZABLE
.isolation
- Value representing a transaction isolation level defined in Connection
.java.sql.SQLException
- If the transaction level cannot be retrievedConnection
,
getTransactionIsolation()
public FBManagedConnectionFactory getManagedConnectionFactory()
FBManagedConnectionFactory
.public void setReadOnly(boolean readOnly)
readOnly
- If true
, the connection will be set read-only, otherwise it will be writablepublic boolean isReadOnly()
true
if this connection is readonly, false
otherwiseCopyright © 2001-2023 Jaybird (Firebird JDBC) team. All rights reserved.