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.
Win: The default database for a Windows node is defined by using the Mimer Administrator to create a System Wide Mimer ODBC Data Source with the name default and associating it with the selected database.
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.
UNIX + VMS: A user-specific default database is defined under UNIX and OpenVMS by setting the environment variable or logical name called MIMER_DATABASE to be the name of the required local or remote database, as stated in the SQLHOSTS file.
If the MIMER_DATABASE variable is set, all default connections will be made to the database it identifies.
Win: A user-specific default database is defined under Windows by using the Mimer Administrator to create a User Specific Mimer ODBC Data Source with the name default and associating this with a database selected by the user. Refer to the online Windows help provided with the Mimer Administrator for details on how to create User Specific Mimer ODBC Data Sources.
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
Win: If using NamedPipes, the operating system user must have an account set up on both the local machine and on the machine where the remote database resides. Both accounts must be set up with the same password.
If using NamedPipes to connect a Mimer SQL version 7.3 client to a Mimer SQL database server version 9 (or 8), it will be necessary to take certain steps to enable network communication.
Under version 7.3 the expected Service name was MIMER, but since version 8 the expected Service name is the name of the database.
Therefore, one of the following must be performed before a version 7.3 client can communicate with a version 8 (or later) remote database server:
1) On each version 7.3 client node, the Service parameter in the remote database definition must be changed to be the name of the database instead of the name MIMER.
2) On the version 9 (or 8) server node, start a NamedPipes server which listens to service MIMER so that it can redirect communications to the correctly named database server.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40