opens a connection to a database - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Connectivity : Database Package : Driver : Database/Driver/OpenConnection

Driver:-OpenConnection - opens a connection to a database

Calling Sequence

driver:-OpenConnection(url, username, password, opts )




Driver module



string; specifying the database



string; username for logging into the database



string or name; password to for logging into the database, 'none', or 'hidden'



(optional) equations of the form option=value where option is one of readonly or isolation



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.


readonly = true or false


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).


Load the JDBC driver and open a connection to the database.



conn1:=moduleoptionunload=Close;localhandle;exportExecuteQuery,ExecuteUpdate,CreateStatement,CreateCallableStatement,CreatePreparedStatement,Commit,Rollback,Close,SetOptions,GetOptions;end module


Open a read-only connection to the same database.


conn2:=moduleoptionunload=Close;localhandle;exportExecuteQuery,ExecuteUpdate,CreateStatement,CreateCallableStatement,CreatePreparedStatement,Commit,Rollback,Close,SetOptions,GetOptions;end module


Open a connection to a different database.


conn3:=moduleoptionunload=Close;localhandle;exportExecuteQuery,ExecuteUpdate,CreateStatement,CreateCallableStatement,CreatePreparedStatement,Commit,Rollback,Close,SetOptions,GetOptions;end module


Load a driver for a different kind of database and open a connection to that database.



conn4:=moduleoptionunload=Close;localhandle;exportExecuteQuery,ExecuteUpdate,CreateStatement,CreateCallableStatement,CreatePreparedStatement,Commit,Rollback,Close,SetOptions,GetOptions;end module


See Also

Database, Database[Connection], Database[Connection][SetOptions], Database[Driver], Database[JDBC], Database[usage]

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam