DB2 Version 9.7 for Linux, UNIX, and Windows

Testing the client-to-server connection using the CLP

Before you begin

After cataloging the node and the database, connect to the database to test the connection. Before testing the connection:

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