|
|
Managing Database Connections
This section describes how users connect to a database and how several simultaneous connections from an application can be handled.
The following SQL statements are used for connection management:
See the Mimer SQL Reference Manual, SQL Statement Descriptions for details.
Selecting a Database
Applications establish database connections with the CONNECT statement, which specifies the database by name.
An application may connect to any of the databases which have been made accessible from the node where the application is running, see Registering the Database. Some applications which are part of the Mimer SQL distribution allow the database name to be specified as a command-line argument.
An application may connect to several databases simultaneously. By using the SQL statement SET CONNECTION the application may switch between active connections. However, a transaction may use only one connection.
The database may be located on the same machine as the application program (a local database), or on a remote machine accessed over a network (a remote database). The network connection is handled by the Mimer SQL software and this is completely transparent to the application program, see Client/Server Interface.
A database is normally accessed by one or more users via the database server. It is also possible for one user to access a local database directly in single-user mode, provided the database server for it is not running and the operating system user has the appropriate access rights to the database files, see Executing in Single-user Mode.
The Default Database
The default database will be used if the CONNECT TO DEFAULT statement is used, or if the database name in the CONNECT statement is specified as an empty string.
The default database can be any of the local or remote databases that are accessible from the node the application program is running on.
The database that is actually selected by a default connection depends on whether a node-specific or user-specific default database is defined at the time the connection is attempted.
Programs supplied as part of the Mimer SQL distribution (e.g. Mimer BSQL) will use the default database when database is not specified on the command line.
Defining a Node-specific Default Database
One default database can be defined for each node in a network.
UNIX + VMS: The default database for UNIX and OpenVMS nodes is defined by specifying the name of the database in the DEFAULT section of the SQLHOSTS file, see The SQLHOSTS File on VMS and UNIX.
Defining a User-specific Default Database
There may be times when an individual user may wish to override the default database defined for the local machine. This is done by defining a user-specific default database, which will be chosen in preference to the node-specific one.
Troubleshooting Remote Database Connect Failures
If an attempt to connect to a remote database fails, the client/server connection can be tested by starting Mimer BSQL on the client node and attempting to connect to the database on the server node.
In the event of a connect failure, the following should be checked:
- If the connect was attempting to access the default database, check that a user-specific or node-specific default database is correctly defined on the client node, see The Default Database for details on how this is done.
- Check that the database been correctly set up as a local database on the server node, see The Local Database, and as a remote database on the client node, see Accessing a Database Remotely, and that the name of the remote database is the same as that of the local database.
- Check that the operating system user who is trying to establish the connection can access all required files etc. on the client node.
- Check that the operating system user who is trying to establish the connection has all the required operating system privileges
- If the TCP/IP protocol is being used, check that the server node is reachable from the client node over the network by using the ping command:
ping server_node
- If the TCP/IP protocol is being used, try to telnet to the TCP/IP port. You should get a connection and when <CR> is entered, the connection should be closed by the server:
telnet server_node 1360
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|