Testing the client-to-server connection using the CLP

If you do not test the client-to-server connection, you might not be able to retrieve information from the database. You should test your client-to-server connection every time you update the authentication type to ensure that the new value is being used.

Before you begin

After cataloging the node and the database, connect to the database to test the connection. Before testing the connection:
  • The database node and database must be cataloged.
  • The values for userid and password must be valid for the system on which they are authenticated. The authentication parameter on the client is be set to match the value on the server or it can be left unspecified. If an authentication parameter is not specified, the client will default to SERVER_ENCRYPT. If the server does not accept SERVER_ENCRYPT, then the client retries using the value returned from the server. If the client specifies an authentication parameter value that doesn't match what is configured on the server, you will receive an error.
  • The database manager must be started with the correct protocol defined in the DB2COMM registry variable. If it is not started, then you can start the database manager by entering the db2start command on the database server.

Procedure

To test the client to server connection:

  1. If you are using a Linux® or UNIX platform, set up the instance environment. Run the startup script:
    For bash, Bourne or Korn shell
       . INSTHOME/sqllib/db2profile
    For C shell
       source INSTHOME/sqllib/db2cshrc
    where: INSTHOME represents the home directory of the instance.
  2. Start the Db2® command line processor. On Windows, issue the db2cmd command from a command prompt. On Linux or UNIX, issue the db2 command from a command prompt.
  3. Type the following command on the client to connect to the remote database:
       db2 => connect to database_alias user userid 
    For example, enter the following command:
    connect to mysample user jtris  
    You will be prompted to enter your password.

Example

If the connection is successful, you receive a message showing the name of the database to which you have connected. A message similar to the following is given:
Database Connection Information     
Database server = DB2/LINUXX8664 11.5.0.0     
SQL authorization ID = JTRIS     
Local database alias = mysample
You can now work with the database. For example, to retrieve a list of all the table names listed in the system catalog table, enter the following SQL statement:
select tabname from syscat.tables

What to do next

When you are finished using the database connection, enter the connect reset command to end the database connection.