IBM Books

Quick Beginnings for DB2 Connect Enterprise Edition


Connecting to a Database

You need to connect to a database before you can use SQL statements to query or update it. The CONNECT statement associates a database connection with a user ID.

A database is created in an instance using one of three different authentication types: CLIENT, SERVER, or DCS. If an authentication type is not specified when the instance is created, the default SERVER authentication is used. Depending on the authentication type and where the database resides, you connect to remote databases differently. While DCE authentication is an option, you cannot specify it when you create an instance. Refer to Administration Guide for more information on all authentication types.

Connecting to a local database

To connect to a local database called SAMPLE, enter the following command in the Command Center or the command line processor:

   connect to sample

Connecting to a remote database


note

If you are connecting to the database from an OS/2 client, and are not currently logged on, you will be prompted to log on using a user ID and password.

If you are connecting to a database from a Windows NT client using CLIENT authentication, and you provide a user ID and password on the connect command, you must start the DB2 for Windows NT Security Service on the system. The Security Service is installed by DB2 and set up to run as a Windows NT service; however, it is not started automatically. To start the DB2 Security Service, enter the net start db2ntsecserver command.

When a successful connection is made, a message similar to the following is displayed:

   Database product       = DB2/NT 5.2.0
   SQL authorization ID   = USERID
   Local database alias   = SAMPLE
   Database Server        = DB2/6000 5.2.0
   SQL authorization ID   = USERID
   Local database alias   = SAMPLE

If you receive an error message, make sure that the SAMPLE database exists on the server and the database manager was started on the server.

Refer to the Administration Guide for more information on authentication.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]