Managing the Database Connection
Managing the Database Connection
To manage the database connection of an adapter, you can use the following properties and methods of the adapter.
Properties
The following properties control or provide information about the database connection:
This read-only property indicates if the adapter is currently connected.
An optional set of SQL connection attribute options. For ODBC, they have the form:
attr:val,attr:val
For example, AutoCommit:1.
For JDBC, they have the form
attr=val;attr=val
For example, TransactionIsolationLevel=TRANSACTION_READ_COMMITTED.
Set this property in the OnInit() method of your business operation or business service to specify the options to use at connection time.
This property specifies the number of seconds to wait on each connection attempt. The default value is 5.
This property specifies whether to stay connected to the remote system:
-
For information on how the SQL inbound adapter uses this setting, see Specifying Other Runtime Settings for the SQL Inbound Adapter.
-
For information on how the SQL outbound adapter uses this setting, see Specifying Other Runtime Settings for the SQL Outbound Adapter.
This data source name specifies the external data source to connect to. The following example shows the name of a DSN that refers to a Microsoft Access database:
accessplayground
Methods
Use the following methods to manage the database connection:
Method Connect(pTimeout As %Numeric = 30) As %Status
Connects to the data source given by the current value of the DSN property.
Method Disconnect() As %Status
Disconnects from the data source.
Method TestConnection()
Tests the connection to the data source.
The adapter classes also provide several setter methods that you can use to set the properties listed in the preceding section.