Service Database
from database import Database
Port Name | Location | Protocol | Interfaces |
---|---|---|---|
ip | local | DatabaseInterface |
List of Available Interfaces
DatabaseInterface
Operation Name | Input Type | Output Type | Faults | Description |
---|---|---|---|---|
beginTx | void | TxHandle | SQLExceptionundefinedConnectionErrorundefined | Designates a connection from the connection pool as an open transaction, and returns an int which can be used to refer to the now open transaction. |
checkConnection | void | void | ConnectionErrorundefined | Checks the connection with the database. Throws ConnectionError if the connection is not functioning properly. |
close | void | void | - | Explicitly closes a database connection Per default the close happens on reconnect or on termination of the Database service, eg. when the enclosing program finishes. |
commitTx | TxHandle | void | TransactionExceptionundefinedSQLExceptionundefinedConnectionErrorundefined | Commits and closes the connection associated with the transaction handle in CommitTransactionRequest. The connection is then returned to the connection pool, and any further actions attempted using the transaction handle will throw a TransactionException. |
connect | ConnectionInfo | void | InvalidDriverundefinedConnectionErrorundefinedDriverClassNotFoundundefined | Connects to a database and closes any potential preexisting database connection. Example with HSQLDB: with ( connectionInfo ) { .username = "sa"; .password = ""; .host = ""; .database = "file:weatherdb/weatherdb"; // "." for memory-only .driver = "hsqldb_embedded" }; connect@Database( connectionInfo )( void ); |
executeTransaction | DatabaseTransactionRequest | DatabaseTransactionResult | SQLExceptionundefinedConnectionErrorundefined | Executes more than one database command in a single transaction |
query | QueryRequest | QueryResult | TransactionExceptionundefinedSQLExceptionundefinedConnectionErrorundefined | Queries the database and returns a result set Example with SQL parameters: queryRequest = "SELECT city, country, data FROM weather " + "WHERE city=:city AND country=:country"; queryRequest.city = City; queryRequest.country = Country; query@Database( queryRequest )( queryResponse ); _template: Field _template allows for the definition of a specific output template. Assume, e.g., to have a table with the following columns: |
rollbackTx | TxHandle | void | TransactionExceptionundefinedSQLExceptionundefinedConnectionErrorundefined | Rolls back and closes the connection associated with the handle TxHandle. The connection is then returned to the connection pool, and any further actions attempted using the transaction handle will throw a TransactionException. |
update | UpdateRequest | int | TransactionExceptionundefinedSQLExceptionundefinedConnectionErrorundefined | Updates the database and returns a single status code Example with SQL parameters: updateRequest = "INSERT INTO weather(city, country, data) " + "VALUES (:city, :country, :data)"; updateRequest.city = City; updateRequest.country = Country; updateRequest.data = r; update@Database( updateRequest )( ret ) To run the update within specific transaction, a transaction handle can be provided along with the updateRequest. To execute the updateRequest above in an open transaction with txHandle 42, we can call update in the following way: updateDatabase@Database( { txHandle = 42 update = updateRequest } )( ret ) |
Types
ConnectionInfo:
Type Declaration
void { database[1,1]: string // password[1,1]: string // checkConnection[0,1]: int // driver[1,1]: string { class[0,1]: string // it allows for specifying a specific driver Java class } // port[0,1]: int // connectionPoolConfig[0,1]: ConnectionPoolConfig // toLowerCase[0,1]: bool // host[1,1]: string // toUpperCase[0,1]: bool // attributes[0,1]: string // username[1,1]: string // }
ConnectionPoolConfig:
Type Declaration
void { transactionIsolation[0,1]: string // initializationFailTimeout[0,1]: int // validationTimeout[0,1]: int // catalog[0,1]: string // readOnly[0,1]: bool // isolateInternalQueries[0,1]: bool // maxLifetime[0,1]: int // connectionInitSql[0,1]: string // minimumIdle[0,1]: int // idleTimeout[0,1]: int // connectionTestQuery[0,1]: string // maximumPoolSize[0,1]: int // connectionTimeout[0,1]: int // poolName[0,1]: string // }