com.apama.database
Event DBUtil


Utility event to present a simplified and easier to use event interface to ADBC.
See Also:
com.apama.database.DBUtil.setAdapterInstanceName() - Please ensure that this has been called to identify the adapter instance to be used before opening any connection to the database.
Routes:
com.apama.database.DBAcknowledge - 
Sends:
com.apama.statusreport.SubscribeStatus - 
com.apama.statusreport.UnsubscribeStatus - 
Listens:
com.apama.database.ResultEvent - 
com.apama.statusreport.Status - 
com.apama.statusreport.StatusError - 

Action summary
 voidclose(boolean doStopAll)

Close the database. Setting doStopAll to true will cancel the current and all outstanding operations.
 voiddoSQLCmd(string cmdString)

Execute a SQL command that does not return results.
 voiddoSQLCmdAck(string cmdString, integer ackNum, boolean onError)

Execute an SQL command that does not return results and receive a DBAcknowledge event to indicate success or failure.
 voiddoSQLCmdOnError(string cmdString)

Execute an SQL command that does not return results unless the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.
 voiddoSQLCommit()

Commit changes to database.
 voiddoSQLCommitAck(integer ackNum)

Commit changes to database and receive a DBAcknowledge event to indicate success or failure.
 voiddoSQLEventQuery(string queryString, string eventType)

Execute an SQL query that returns events.
 voiddoSQLEventQueryAck(string queryString, string eventType, integer ackNum, boolean onError)

Execute a SQL query that returns events and receive a DBAcknowledge event to indicate success or failure.
 voiddoSQLEventQueryOnError(string queryString, string eventType)

Execute a SQL query that returns events but only if the previous operation (SQLCmd, SQLQuery, SQLEventQuery, or SQLCommit) failed.
 voiddoSQLEventQueryWithCallback(string queryString, string eventType, action<stringinteger> handleDone)

Execute a SQL query that returns events and runs the specified action when the query completes. The handleDone action parameters are : string error - Will be empty on success else the error message integer count - Number of rows returned by the query.
 voiddoSQLQuery(string queryString, action<dictionary<stringstring>> handleResult)

Execute a SQL query that returns results.
 voiddoSQLQueryAck(string queryString, action<dictionary<stringstring>> handleResult, integer ackNum, boolean onError)

Execute a SQL query that returns results and receive a DBAcknowledge event to indicate success or failure.
 voiddoSQLQueryOnError(string queryString, action<dictionary<stringstring>> handleResult)

Execute an SQL query that returns results but only if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.
 voiddoSQLQueryWithCallback(string queryString, action<dictionary<stringstring>> handleResult, action<stringinteger> handleDone)

Execute a SQL query that returns results and runs the specified action when the query completes. The handleDone action parameters are : string error - Will be empty on success else the error message integer count - Number of rows returned by the query.
 voiddoSQLRollback()

Rollback uncommitted changes to database.
 voiddoSQLRollbackAck(integer ackNum, boolean onError)

Rollback uncommitted changes to database and receive a DBAcknowledge event to indicate success or failure.
 voiddoSQLRollbackOnError()

Rollback uncommitted changes to database but only if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.
 sequence<string>getSchemaFieldOrder()

Get the current schemas field order associated with the current result.
 dictionary<stringstring>getSchemaFieldTypes()

Get the current schemas field types associated with the current result.
 sequence<string>getSchemaIndexFields()

Get the current schemas index field associated with the current result.
 voidhandleDoneDefault(string error, integer count)

Callback action to handle the completion of a query. Called after entire ResultSet is returned.
 voidhandleResultsDefault(dictionary<stringstring> r)

Callback action to handle a ResultEvent from a query. Called for each ResultEvent (row) returned.
 booleanisOpen()

Test if the connection is open (or in the process of opening).
 voidonConcludeRecovery()

OnConcludeRecovery is called after the recovery process has been completed, including all non persistent monitors having being re-loaded.
 voidopen(string type, string serviceId, string URL, string user, string password, string autoCommit, boolean readOnly, integer batchSize, float timeOut, action<string> errorHandler)

Open that allows for specifying the serviceId, as well as autoCommit, batchSize, and the timeOut for waiting for adapter.
 voidopenQuickJDBC(string URL, string user, string password, action<string> handleError)

Quick open operation for JDBC. Uses default batch size, auto commit, etc.
 voidopenQuickODBC(string URL, string user, string password, action<string> handleError)

Quick open operation for ODBC. Uses default batch size, auto commit, etc.
 voidopenShared(string type, string serviceId, string URL, string user, string password, string autoCommit, boolean readOnly, integer batchSize, float timeOut, action<string> errorHandler)

Open that uses an already open existing matching connection if available or will open a new one. Allows for specifying the serviceId, as well as autoCommit, batchSize, and the timeOut for waiting for adapter.
 voidsetAdapterInstanceName(string instanceName)

Set the adapter instance name for use with the openQuick actions. setAdapterInstanceName should always be called to set the instance name.
 voidsetLogQueries(boolean logQueries)

Enable (or disable) the logging of all operations (SQLQuery, SQLCmd and SQLCommit). The default setting is disabled (false).
 voidsetPrespawnContext(context ctx)

Set context that is current prior to spawning. Optional: Only needed when using parallel processing.
 voidsetReconnectOverrideTimeout(float timeOut)

Set the timout for the reconnection after a conection error. The default value is set by the open action to be twice as long as its timeOut parameter.
 voidsetReconnectPolicy(string reconnectPolicy)

Set the policy for the dealing with adapter connection errors.
 voidsetReconnectTimeout(float timeOut)

Set the timout for the reconnection after a conection error. The default value is set by the open action to be twice as long as its timeOut parameter.
 voidshutdownConnectionOnError()

Shutdown the connection when there is an error.
 voidstopAll()

Stop all operations. This also cancels all outstanding queries in the queue.
 voidsubscribeStatus()

Subscribe to the status information from all ADBC adapters.
 
Action detail

close

void close(boolean doStopAll)
Close the database. Setting doStopAll to true will cancel the current and all outstanding operations.
Parameters:
doStopAll - Should all pending operations be canceled.

doSQLCmd

void doSQLCmd(string cmdString)
Execute a SQL command that does not return results.
Parameters:
cmdString - Command to execute.

doSQLCmdAck

void doSQLCmdAck(string cmdString, integer ackNum, boolean onError)
Execute an SQL command that does not return results and receive a DBAcknowledge event to indicate success or failure.

Setting onError to true will cause this command to only be run if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed. Setting ackNum to -1 will disable sending the DBAcknowledge event and instead use the default error handler if an error occurs.
Parameters:
cmdString - Command to execute.
ackNum - The id of DBAcknowledge event.
onError - Indicates if it should run only when there is an error.

doSQLCmdOnError

void doSQLCmdOnError(string cmdString)
Execute an SQL command that does not return results unless the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.
Parameters:
cmdString - Command to execute.

doSQLCommit

void doSQLCommit()
Commit changes to database.

doSQLCommitAck

void doSQLCommitAck(integer ackNum)
Commit changes to database and receive a DBAcknowledge event to indicate success or failure.

Setting ackNum to -1 will disable sending the DBAcknowledge event and instead use the default error handler if an error occurs.
Parameters:
ackNum - The id for the DBAcknowledge event.

doSQLEventQuery

void doSQLEventQuery(string queryString, string eventType)
Execute an SQL query that returns events.
Parameters:
queryString - Query to execute.
eventType - Event type for mapping rule (_ADBCType).

doSQLEventQueryAck

void doSQLEventQueryAck(string queryString, string eventType, integer ackNum, boolean onError)
Execute a SQL query that returns events and receive a DBAcknowledge event to indicate success or failure.

Setting onError to true will cause this command to only be run if the previous operation (SQLCmd, SQLQuery, SQLEventQuery, or SQLCommit) failed. Setting ackNum to -1 will disable sending the DBAcknowledge event and instead use the default error handler if an error occurs.
Parameters:
queryString - Query to execute.
eventType - Event type for mapping rule (_ADBCType).
ackNum - The id for the DBAcknowledge event.
onError - Indicates if it should run only when there is an error.

doSQLEventQueryOnError

void doSQLEventQueryOnError(string queryString, string eventType)
Execute a SQL query that returns events but only if the previous operation (SQLCmd, SQLQuery, SQLEventQuery, or SQLCommit) failed.
Parameters:
queryString - Query to execute.
eventType - Event type for mapping rule (_ADBCType).

doSQLEventQueryWithCallback

void doSQLEventQueryWithCallback(string queryString, string eventType, action<stringinteger> handleDone)
Execute a SQL query that returns events and runs the specified action when the query completes. The handleDone action parameters are : string error - Will be empty on success else the error message integer count - Number of rows returned by the query.
Parameters:
queryString - Query to execute.
eventType
handleDone - Callback to be called when the query fully completes.

doSQLQuery

void doSQLQuery(string queryString, action<dictionary<stringstring>> handleResult)
Execute a SQL query that returns results.
Parameters:
queryString - Query to execute.
handleResult - Callback to be called for each ResultEvent (row).

doSQLQueryAck

void doSQLQueryAck(string queryString, action<dictionary<stringstring>> handleResult, integer ackNum, boolean onError)
Execute a SQL query that returns results and receive a DBAcknowledge event to indicate success or failure.

Setting onError to true will cause this command to only be run if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed. Setting ackNum to -1 will disable sending the DBAcknowledge event and instead use the default error handler if an error occurs.
Parameters:
queryString - Query to execute.
handleResult - Callback to be called for each ResultEvent (row).
ackNum - The id for the DBAcknowledge event.
onError - Indicates if it should run only when there is an error.

doSQLQueryOnError

void doSQLQueryOnError(string queryString, action<dictionary<stringstring>> handleResult)
Execute an SQL query that returns results but only if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.
Parameters:
queryString - Query to execute.
handleResult - Callback to be called for each ResultEvent (row).

doSQLQueryWithCallback

void doSQLQueryWithCallback(string queryString, action<dictionary<stringstring>> handleResult, action<stringinteger> handleDone)
Execute a SQL query that returns results and runs the specified action when the query completes. The handleDone action parameters are : string error - Will be empty on success else the error message integer count - Number of rows returned by the query.
Parameters:
queryString - Query to execute.
handleResult - Callback to be called for each ResultEvent (row).
handleDone - Callback to be called when the query fully completes.

doSQLRollback

void doSQLRollback()
Rollback uncommitted changes to database.

doSQLRollbackAck

void doSQLRollbackAck(integer ackNum, boolean onError)
Rollback uncommitted changes to database and receive a DBAcknowledge event to indicate success or failure.

Setting onError to true will cause this to run only if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed. Setting ackNum to -1 will disable sending the DBAcknowledge event and instead use the default error handler if an error occurs.
Parameters:
ackNum - The id for the DBAcknowledge event.
onError - Indicates if it should run only when there is an error.

doSQLRollbackOnError

void doSQLRollbackOnError()
Rollback uncommitted changes to database but only if the previous operation (SQLCmd, SQLQuery, or SQLCommit) failed.

getSchemaFieldOrder

sequence<stringgetSchemaFieldOrder()
Get the current schemas field order associated with the current result.

getSchemaFieldTypes

dictionary<stringstringgetSchemaFieldTypes()
Get the current schemas field types associated with the current result.

getSchemaIndexFields

sequence<stringgetSchemaIndexFields()
Get the current schemas index field associated with the current result.

handleDoneDefault

void handleDoneDefault(string error, integer count)
Callback action to handle the completion of a query. Called after entire ResultSet is returned.

This is a no-op handler.
Parameters:
error
count

handleResultsDefault

void handleResultsDefault(dictionary<stringstring> r)
Callback action to handle a ResultEvent from a query. Called for each ResultEvent (row) returned.

This is a no-op handler.
Parameters:
r

isOpen

boolean isOpen()
Test if the connection is open (or in the process of opening).

onConcludeRecovery

void onConcludeRecovery()
OnConcludeRecovery is called after the recovery process has been completed, including all non persistent monitors having being re-loaded.
Listens:
com.apama.statusreport.Status - 

open

void open(string type, string serviceId, string URL, string user, string password, string autoCommit, boolean readOnly, integer batchSize, float timeOut, action<string> errorHandler)
Open that allows for specifying the serviceId, as well as autoCommit, batchSize, and the timeOut for waiting for adapter.
Parameters:
type - Data source type (ODBC, JDBC, Sim, etc,).
serviceId - Service id for the adapter (com.apama.adbc.ODBC, com.apama.adbc.JDBC, etc.).
URL - Database connection string.
user - User name (if required).
password - User password (if required).
autoCommit - Auto-commit mode (case insensitive values):
 default - Use setting from config file.
false - Disable auto-commit.
x.x - Value (seconds) for ADBC adapter timed auto-commit.
true - Enable data source specific auto-commit.
readOnly - Should connection be readOnly.
batchSize - The maximum size of a batch.
timeOut - Time to wait for adapter to become ready.
errorHandler - Callback action for any failures.
See Also:
com.apama.database.DBUtil.setAdapterInstanceName() - Please ensure that this has been called to identify the adapter instance to be used before opening any connection to the database, unless specified as part of the serviceId.
Listens:
com.apama.statusreport.Status - 

openQuickJDBC

void openQuickJDBC(string URL, string user, string password, action<string> handleError)
Quick open operation for JDBC. Uses default batch size, auto commit, etc.
Parameters:
URL - Database connection string.
user - User name (if required).
password - User password (if required).
handleError
See Also:
com.apama.database.DBUtil.setAdapterInstanceName() - Please ensure that this has been called to identify the adapter instance to be used before opening any connection to the database.

openQuickODBC

void openQuickODBC(string URL, string user, string password, action<string> handleError)
Quick open operation for ODBC. Uses default batch size, auto commit, etc.
Parameters:
URL - Database connection string.
user - User name (if required).
password - User password (if required).
handleError
See Also:
com.apama.database.DBUtil.setAdapterInstanceName() - Please ensure that this has been called to identify the adapter instance to be used before opening any connection to the database.

openShared

void openShared(string type, string serviceId, string URL, string user, string password, string autoCommit, boolean readOnly, integer batchSize, float timeOut, action<string> errorHandler)
Open that uses an already open existing matching connection if available or will open a new one. Allows for specifying the serviceId, as well as autoCommit, batchSize, and the timeOut for waiting for adapter.
Parameters:
type - Data source type (ODBC, JDBC, Sim, etc,).
serviceId - Service id for the adapter (com.apama.adbc.ODBC, com.apama.adbc.JDBC, etc.).
URL - Database connection string.
user - User name (if required).
password - User password (if required).
autoCommit - Auto-commit mode (case insensitive values):
 default - Use setting from config file.
false - Disable auto-commit.
x.x - Value (seconds) for ADBC adapter timed auto-commit.
true - Enable data source specific auto-commit.
readOnly - Should connection be readOnly.
batchSize - The maximum size of a batch.
timeOut - Time to wait for adapter to become ready.
errorHandler - Callback action for any failures.
See Also:
com.apama.database.DBUtil.setAdapterInstanceName() - Please ensure that this has been called to identify the adapter instance to be used before opening any connection to the database, unless specified as part of the serviceId.
Listens:
com.apama.statusreport.Status - 

setAdapterInstanceName

void setAdapterInstanceName(string instanceName)
Set the adapter instance name for use with the openQuick actions. setAdapterInstanceName should always be called to set the instance name.
Parameters:
instanceName - The ADBC adapter instance name, e.g. "JDBCAdapter1".

setLogQueries

void setLogQueries(boolean logQueries)
Enable (or disable) the logging of all operations (SQLQuery, SQLCmd and SQLCommit). The default setting is disabled (false).
Parameters:
logQueries - If true will enable logging.

setPrespawnContext

void setPrespawnContext(context ctx)
Set context that is current prior to spawning. Optional: Only needed when using parallel processing.
Parameters:
ctx - Current context prior to spawning.

setReconnectOverrideTimeout

void setReconnectOverrideTimeout(float timeOut)
Set the timout for the reconnection after a conection error. The default value is set by the open action to be twice as long as its timeOut parameter.
Parameters:
timeOut - The reconnection timeout.

setReconnectPolicy

void setReconnectPolicy(string reconnectPolicy)
Set the policy for the dealing with adapter connection errors.

The reconnectPolicy parameter must be one of the constants from DBReconnectPolicy event. See DBReconnectPolicy event for the policy descriptions. The default reconnect policy is DO_NOT_RECONNECT.
Parameters:
reconnectPolicy - Indicates the reconnection policy to use after a disconnect.

setReconnectTimeout

void setReconnectTimeout(float timeOut)
Set the timout for the reconnection after a conection error. The default value is set by the open action to be twice as long as its timeOut parameter.
Parameters:
timeOut - The reconnection timeout.

shutdownConnectionOnError

void shutdownConnectionOnError()
Shutdown the connection when there is an error.

Marks the connection as closed and quits all listeners, this also unsubscribes from ADBC status information.
Sends:
com.apama.statusreport.UnsubscribeStatus - 

stopAll

void stopAll()
Stop all operations. This also cancels all outstanding queries in the queue.

subscribeStatus

void subscribeStatus()
Subscribe to the status information from all ADBC adapters.
Sends:
com.apama.statusreport.SubscribeStatus -