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.
To connect to a local database called SAMPLE, type the following command in the Command Center or the command line processor:
connect to sample
connect to sample user userid using password
(Be sure to choose values for userid and password that are valid on the server system.)
connect to sample
|
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, double-click on the
Services icon in the Control Panel folder. Select
the DB2 Security Server option and click on the Start
push button.
|
When a successful connection is made, a message similar to the following is displayed:
Database product = DB2/6000 5.0.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.
For more information on authentication, refer to the Administration Guide.