Driver:-OpenConnection - opens a connection to a database
|
Calling Sequence
|
|
driver:-OpenConnection(url, username, password, opts )
|
|
Parameters
|
|
driver
|
-
|
Driver module
|
url
|
-
|
string; specifying the database
|
username
|
-
|
string; username for logging into the database
|
password
|
-
|
string or name; password to for logging into the database, 'none', or 'hidden'
|
opts
|
-
|
(optional) equations of the form option=value where option is one of readonly or isolation
|
|
|
|
|
Description
|
|
•
|
OpenConnection opens a connection to a database using the JDBC Driver represented by driver. The argument url specifies the database. username is the name to use for logging in. If password is a string then it is used as the password when logging in. If password is none then no password is used when logging in. If password is hidden, then a Maplet application, which allows the password to be entered without it appearing on screen, is opened.
|
•
|
The value of url depends on the type of database, the JDBC driver and where the database is installed. However the basic format is "jdbc:driver://hostname/DBName". driver is an identifier for the JDBC driver being used. hostname is the name of the computer on which the database is installed. hostname might also include a port number if the default port is incorrect. DBName is the name of the particular database. For the correct values, consult the documentation for the JDBC driver you are using. For more information about JDBC drivers, see JDBC.
|
•
|
For a general overview of using Database, see the usage page.
|
•
|
OpenConnection accepts all the arguments that can be set on a Connection using SetOptions. The valid options are readonly and isolation.
|
|
The readonly optional argument informs the database that it can enable optimizations associated with a read-only connection. The effect depends on the database. Setting readonly=true may or may not prevent the execution of updates. By default, connections are not opened read-only.
|
|
isolation = uncommittedread, committedread, repeatableread or serializable
|
|
The isolation optional argument determines how isolated transactions using this connection are from transactions occurring at the same time.
|
|
- At serializable isolation, dirty reads (reading uncommitted data from parallel transactions), non-repeatable reads (reading the same row multiple times producing different results due to parallel updates), and phantom reads (WHERE conditions matching different numbers of rows due to parallel updates) are all prevented.
|
|
- At repeatableread isolation, dirty reads and non-repeatable reads are prevented.
|
|
- At committedread, only dirty reads are prevented.
|
|
- At uncommittedread isolation, dirty reads are also allowed.
|
|
The default isolation is database specific.
|
•
|
OpenConnection can be used to open multiple parallel connections to a single database or multiple connections to different databases (assuming they are all compatible with driver).
|
|
|
Examples
|
|
Load the JDBC driver and open a connection to the database.
>
|
|
>
|
|
| (1) |
Open a read-only connection to the same database.
>
|
|
| (2) |
Open a connection to a different database.
>
|
|
| (3) |
Load a driver for a different kind of database and open a connection to that database.
>
|
|
>
|
|
| (4) |
|
|
Download Help Document
Was this information helpful?