Apama 10.15.1 | Connecting Apama Applications to External Components | Standard IAF Plug-ins | The Database Connector IAF Adapter (ADBC) | The ADBC Event application programming interface | Closing a database
 
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 in the samples\adbc\api-example\ADBC_Example.mon file 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;    
}  
}