public interface DatabaseQueryActivity
The procedure to send asynchronous queries is:
DatabaseResultEvent
eventDatabaseQueryFailureEvent
eventprivate void asyncRequest(String shortCode) { try { DatabaseQueryActivity queryActivity = dbProvider.createActivity(); 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) { aci.detach(getSbbLocalObject()); ResultSet rs = result.getResultSet(); // ... handle result ... } public void onDatabaseQueryFailure(DatabaseQueryFailureEvent failure, ActivityContextInterface aci) { aci.detach(getSbbLocalObject()); // ... handle failure ... }
void sendQuery(QueryInfo queryInfo) throws NoDataSourcesAvailableException
DatabaseResultEvent
event on this activity. Failed queries will be fired as a DatabaseQueryFailureEvent
.
The activity will end when the result event is fired and it cannot be used again.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