Interface DatabaseTransaction
-
public interface DatabaseTransaction
Defines an interface for synchronous queries to interact with a explicit transaction. To store this transaction in CMP, callmarshal()
and store the result. To retrieve the transaction object callDatabaseQueryProvider.unmarshalTransaction(byte[])
passing in the marshaled handle.- Since:
- 1.2
- Author:
- OpenCloud
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
commit(long timeout)
Call commit on the connection.byte[]
marshal()
Return a handle that can be later passed toDatabaseQueryProvider.unmarshalTransaction(byte[])
.void
rollback(long timeout)
Call rollback on the connection.void
setTransactionIsolation(int level)
Set a transaction isolation level.
-
-
-
Method Detail
-
commit
void commit(long timeout) throws SQLException, TimeoutException, InsufficientResourcesException, DatabaseQueryException
Call commit on the connection. This will also close the connection associated with this transaction (returns it to the pool).- Parameters:
timeout
- timeout in milliseconds- Throws:
SQLException
- if an SQL exception occurred executing the query or retrieving the result setTimeoutException
- if a timeout occurred waiting for a worker thread or for the database to returnInsufficientResourcesException
- if the request was rejected due to lack of worker threadsDatabaseQueryException
- for any other problem
-
rollback
void rollback(long timeout) throws SQLException, TimeoutException, DatabaseQueryException, InsufficientResourcesException
Call rollback on the connection. This will also close the connection associated with this transaction (returns it to the pool).- Parameters:
timeout
- timeout in milliseconds- Throws:
SQLException
- if an SQL exception occurred executing the query or retrieving the result setTimeoutException
- if a timeout occurred waiting for a worker thread or for the database to returnInsufficientResourcesException
- if the request was rejected due to lack of worker threadsDatabaseQueryException
- for any other problem
-
marshal
byte[] marshal()
Return a handle that can be later passed toDatabaseQueryProvider.unmarshalTransaction(byte[])
.- Returns:
- an opaque transaction handle suitable for storing in CMP
-
setTransactionIsolation
void setTransactionIsolation(int level)
Set a transaction isolation level. The given level will be passed toConnection.setTransactionIsolation(int)
when a connection is first retrieved for this transaction. The constants defined in the interfaceConnection
are the possible transaction isolation levels.- Parameters:
level
- one of the followingConnection
constants:Connection.TRANSACTION_READ_UNCOMMITTED
,Connection.TRANSACTION_READ_COMMITTED
,Connection.TRANSACTION_REPEATABLE_READ
, orConnection.TRANSACTION_SERIALIZABLE
. (Note thatConnection.TRANSACTION_NONE
cannot be used because it specifies that transactions are not supported.)
-
-