Connecting Apama Applications to External Components > Using Standard Adapters > Using the Apama Database Connector > 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 then {
log "Error closing database " + getDbName() + ": " +
     error at ERROR;
}
else {
log "Database " + getDbName() + " closed." at INFO;    
}  
}
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.