Closing a database
In order to close a database your application should implement the following steps:
1. Call the closeDatabase() action of the Connection event (for the open database) with the name of the callback action.
2. Create a handler action for the closeDatabase callback action.
The definitions for the two forms of the closeDatabase() action are:
action closeDatabase(
action <Connection, string> callback)
and
action closeDatabaseFull(
boolean force,
dictionary<string,string> extraParams,
action<Connection,string> callback)
The relevant code is similar to this:
com.apama.database.Connection conn :=
new com.apama.database.Connection;
// ...
conn.openDatabase(serviceId, results[0].dbUrl, "",
handleOpenDatabase);
// ...
conn.closeDatabase(handleCloseDatabase);
action handleCloseDatabase(com.apama.database.Connection conn,
string error)
{
if error.length() != 0 {
log "Error closing database " + getDbName() + ": " +
error at ERROR;
}
else {
log "Database " + getDbName() + " closed." at INFO;
}
}