public interface DatabaseQueryTransactionalActivity
commit()
or rollback()
.
The procedure to send transactional asynchronous queries is:
DatabaseResultEvent
eventDatabaseQueryFailureEvent
eventcommit()
or rollback()
private void asyncRequest(String shortCode) { try { DatabaseQueryTransactionalActivity queryActivity = dbProvider.createTransactionalActivity(); ActivityContextInterface dbAci = dbACIFactory.getActivityContextInterface(queryActivity); dbAci.attach(getSbbLocalObject()); queryActivity.sendQuery(new SelectLongCodeQueryInfo(shortCode)); } catch (StartActivityException e) { // ... handle exception ... } catch (NoDataSourcesAvailableException e) { // ... handle exception ... } } public void onDatabaseResult(DatabaseResultEvent result, ActivityContextInterface aci) { ResultSet rs = result.getResultSet(); // ... handle result ... } public void onDatabaseQueryFailure(DatabaseQueryFailureEvent failure, ActivityContextInterface aci) { aci.detach(getSbbLocalObject()); // ... handle failure ... } private void commit() { DatabaseQueryTransactionalActivity queryActivity = retrieveActivity(); if(queryActivity != null) { queryActivity.commit(); } }
Modifier and Type | Method and Description |
---|---|
void |
commit()
Call commit on the connection in use by the transaction associated with this result.
|
void |
rollback()
Call rollback on the connection in use by the transaction associated with this result.
|
void |
sendQuery(QueryInfo queryInfo)
Send a query asynchronously.
|
void |
setTransactionIsolation(int level)
Set a transaction isolation level.
|
void sendQuery(QueryInfo queryInfo) throws NoDataSourcesAvailableException
DatabaseResultEvent
event on this activity. Failed queries will be fired as a DatabaseQueryFailureEvent
.queryInfo
- a callback object to get the query string and set parameters for the SQL statementNoDataSourcesAvailableException
- if there are no configured data sources currently marked as available
when trying to get a connection for the first queryvoid commit()
DatabaseResultEvent
will be fired
on this activity. Failed commits will be fired as a DatabaseQueryFailureEvent
.void rollback()
DatabaseResultEvent
will be fired
on this activity. Failed rollbacks will be fired as a DatabaseQueryFailureEvent
.void setTransactionIsolation(int level)
Connection.setTransactionIsolation(int)
when a connection is first retrieved for this transaction.
The constants defined in the interface Connection
are the possible transaction isolation levels.
level
- one of the following Connection
constants:
Connection.TRANSACTION_READ_UNCOMMITTED
,
Connection.TRANSACTION_READ_COMMITTED
,
Connection.TRANSACTION_REPEATABLE_READ
, or
Connection.TRANSACTION_SERIALIZABLE
.
(Note that Connection.TRANSACTION_NONE
cannot be used
because it specifies that transactions are not supported.)