- All Implemented Interfaces:
ExceptionListener
XAResource
.- Author:
- David Jencks, Mark Rotteveel
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add anXcaConnectionEventListener
listener.void
cleanup()
Application server calls this method to force any cleanup on the managed connection instance.void
Close this connection with regard to a wrappingAbstractConnection
.void
destroy()
Destroys the physical connection to the underlying resource manager.void
destroy
(XcaConnectionEvent connectionEvent) void
errorOccurred
(Object source, SQLException ex) Notify about a SQLExceptionCreates a new connection handle for the underlying physical connection represented by the managed connection instance.Get information about the current connection parameters.Get instance ofGDSHelper
connected with this managed connection.Returns aFBLocalTransaction
instance.Get the managed connection factory that created this managed connection.int
Get the transaction isolation level of this connection.getTransactionParameters
(int isolation) Returns anjavax.transaction.xa.XAResource
instance.boolean
void
internalStart
(Xid id, int flags) Perform the internal processing to start associate a JDBC connection with a global transaction.void
internalStart
(Xid xid, String sql) Starts a transaction defined bysetTransactionSql
, and associate it with a JDBC connection.boolean
boolean
boolean
boolean
Returns if the current TPB has the auto-commit flag set.boolean
Retrieve whether the current TPB is read-only.void
Remove aXcaConnectionEventListener
from the listing of listeners that will be notified for aXcaConnectionEvent
.void
setManagedEnvironment
(boolean managedEnvironment) void
setTpbAutoCommit
(boolean autoCommit) Sets the Firebird auto-commit flag on the current TPB.void
setTpbReadOnly
(boolean readOnly) Set the current TPB to read-only.void
setTransactionIsolation
(int isolation) Set the transaction level for this connection.void
setTransactionParameters
(int isolation, TransactionParameterBuffer transactionParams) void
setTransactionParameters
(TransactionParameterBuffer transactionParams) Sets the current TPB to a copy oftransactionParams
.withLock()
-
Method Details
-
errorOccurred
Description copied from interface:ExceptionListener
Notify about a SQLException- Specified by:
errorOccurred
in interfaceExceptionListener
- Parameters:
source
- The source of the event; note for caller: this should be the object this listener is registered at.ex
- error that occurred.
-
getGDSHelper
Get instance ofGDSHelper
connected with this managed connection.- Returns:
- instance of
GDSHelper
. - Throws:
SQLException
- If this connection has no GDSHelper
-
isManagedEnvironment
public boolean isManagedEnvironment() -
inTransaction
public boolean inTransaction() -
setManagedEnvironment
- Throws:
SQLException
-
getLocalTransaction
Returns aFBLocalTransaction
instance.The FBLocalTransaction is used by the container to manage local transactions for a RM instance.
- Returns:
- FBLocalTransaction instance
-
addConnectionEventListener
Add anXcaConnectionEventListener
listener. The listener will be notified when aXcaConnectionEvent
occurs.- Parameters:
listener
- TheXcaConnectionEventListener
to be added
-
removeConnectionEventListener
Remove aXcaConnectionEventListener
from the listing of listeners that will be notified for aXcaConnectionEvent
.- Parameters:
listener
- TheFirebirdConnectionEventListener
to be removed
-
cleanup
Application server calls this method to force any cleanup on the managed connection instance.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.
- Throws:
SQLException
- generic exception if operation fails
-
getConnection
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:
SQLException
- generic exception if operation fails
-
destroy
Destroys the physical connection to the underlying resource manager.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.- Throws:
SQLException
- generic exception if operation failed
-
destroy
- Throws:
SQLException
-
getXAResource
Returns anjavax.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.- Returns:
- XAResource instance
-
withLock
- See Also:
-
isLockedByCurrentThread
public boolean isLockedByCurrentThread()- See Also:
-
inDistributedTransaction
public boolean inDistributedTransaction() -
internalStart
Perform the internal processing to start associate a JDBC connection with a global transaction.- Parameters:
id
- A global transaction identifier to be associated with the resourceflags
- One of TMNOFLAGS, TMJOIN, or TMRESUME- Throws:
XAException
- If the transaction is already started, or this connection cannot participate in the distributed transactionSQLException
- See Also:
-
start(Xid, int)
-
internalStart
Starts a transaction defined bysetTransactionSql
, and associate it with a JDBC connection.- Parameters:
xid
- global transaction identifier to be associated with the resourcesql
-SET TRANSACTION
statement text- Throws:
XAException
- if this connection cannot participate in the distributed transactionSQLException
- for database access errors
-
close
Close this connection with regard to a wrappingAbstractConnection
.- Parameters:
c
- TheAbstractConnection
that is being closed
-
getConnectionRequestInfo
Get information about the current connection parameters.- Returns:
- instance of
FBConnectionRequestInfo
.
-
getTransactionParameters
- Returns:
- a copy of the current TPB
-
setTransactionParameters
Sets the current TPB to a copy oftransactionParams
.- Parameters:
transactionParams
- transaction parameters
-
getTransactionParameters
-
setTransactionParameters
public void setTransactionParameters(int isolation, TransactionParameterBuffer transactionParams) throws SQLException - Throws:
SQLException
-
getTransactionIsolation
Get 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:
SQLException
- If the transaction level cannot be retrieved- See Also:
-
setTransactionIsolation
Set 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 inConnection
.- Throws:
SQLException
- If the transaction level cannot be retrieved- See Also:
-
getManagedConnectionFactory
Get the managed connection factory that created this managed connection.- Returns:
- instance of
FBManagedConnectionFactory
.
-
setTpbReadOnly
public void setTpbReadOnly(boolean readOnly) Set the current TPB to read-only.- Parameters:
readOnly
- iftrue
, the connection will be set read-only, otherwise it will be writable- Since:
- 6
-
isTpbReadOnly
public boolean isTpbReadOnly()Retrieve whether the current TPB is read-only.- Returns:
true
if this connection is readonly,false
otherwise- Since:
- 6
-
setTpbAutoCommit
public void setTpbAutoCommit(boolean autoCommit) Sets the Firebird auto-commit flag on the current TPB. This change is transient and will be reset when the transaction isolation level is set again or the TPB is otherwise replaced.This shouldn't be confused with the normal JDBC auto-commit behavior. Effectively, setting this to
true
will result in Firebird using commit retain after each executed statement.- Parameters:
autoCommit
-true
add the auto-commit flag, otherwise remove it- Since:
- 6
- See Also:
-
isTpbAutoCommit
public boolean isTpbAutoCommit()Returns if the current TPB has the auto-commit flag set.- Returns:
true
if the current TPB has the auto-commit flag,false
otherwise- Since:
- 6
- See Also:
-