The sqlhosts information in a Windows environment

The registry contains the following connection information:
  • The sqlhosts information defines a connection to an established database server.

    This information includes the name of the host computer, the type of protocol to use, and the name of the connection. The Registry stores the sqlhosts information in the SqlHosts subkey of the HCL OneDB™ key. To store sqlhosts information in the Registry, use the Server Information tab of the Setnet32 utility.

  • The .netrc information defines a valid user for a remote connection.

    On UNIX™ operating systems, this file is in the home directory of the user and specifies the name and password for the user account. In Windows™ environments, the NETRC subkey of the HCL OneDB key in the Registry stores the same account information. To store .netrc information in the Registry, use the Host Information tab of the Setnet32 utility.

The client sends network parameters to establish a connection to a database server. The first step in establishing a connection is to log on to the correct host computer. The protocol software uses the network parameters for the current database server. The client locates the network parameters for the current database server in either of the following ways:
  1. If the SQL statement that requests the connection (such as a CONNECT or DATABASE) specifies the name of a database server, the client sends the network parameters for this specified database server.

    If the InfxServer field of InetLogin contains the name of the specified database server, the client checks InetLogin for the network parameters. Otherwise, the client obtains network parameters for that database server from the in-memory copy of the Registry.

  2. If the SQL statement does not specify a database server, the client sends the network parameters for the default database server.

    If the InfxServer field of InetLogin contains the name of a database server, the client checks InetLogin for the network parameters. Otherwise, the client determines the default database server from the ONEDB_SERVER value in the in-memory copy of the Registry. It then sends network parameter values from the Registry for that database server.

checks the network parameter fields of InetLogin for any of these network parameters that the application has currently set. For any fields (including the name of the default database server) that are not set, obtains the values from the in-memory copy of the Registry. (For more information, see Precedence of configuration values.)

For example, the following code fragment initializes the InetLogin structure with information for the mainsrvr database server; mainsrvr is the default database server.
void *cnctHndl;
;

strcpy(InetLogin.InfxServer, "mainsrvr");
strcpy(InetLogin.User, "finance");
strcpy(InetLogin.Password, "in2money");
EXEC SQL connect to 'accounts';
;

QL connect to 'custhist@bcksrvr';
When execution reaches the first CONNECT statement in the preceding code fragment, the client application requests a connection to the accounts database on the mainsrvr database server. The CONNECT statement does not specify a database server, so the client sends the following network parameters for default database server:
  • The default database server is mainsrvr because InfxServer is set in InetLogin.
  • The User and Password values are finance and in2money because the application sets them in InetLogin.
  • The Host, Service, Protocol, and AskPassAtConnect values are from the mainsrvr subkey of the Registry values, because the application does not set them in InetLogin.

The second CONNECT statement in preceding code fragment requests a connection to the custhist database on the bcksrvr database server. For this connection, the client sends the network parameters for the specified database server, bcksrvr. Because the InetLogin structure currently contains network parameters for mainsrvr, the client must obtain all these parameters from the in-memory copy of the Registry. Therefore, the application does not use the finance user account for this second connection (unless the Registry specifies User and Password values of finance and in2money for the bcksrvr database server).

If you are enabling single-sign on (SSO), the process differs. Details and additional steps for configuration, see Configuring ESQL/C and ODBC drivers for SSO.