Testing the embedded SQL database connectivity with the db2dsdriver.cfg file

You can test the embedded SQL database connectivity with the db2dsdriver.cfg file to ensure that the db2dsdriver.cfg file is valid, and that the embedded SQL component is installed correctly.

Before you begin

You must ensure that the IBM® data server client or IBM Data Server Driver Package software is installed and the db2dsdriver.cfg file is created in your environment with a required data source name (DSN) entry. You can use the contents of the db2dsdriver.cfg.sample file to create the db2dsdriver.cfg file.

Procedure

To test the embedded SQL database connectivity with the db2dsdriver.cfg file:

Issue the db2cli validate -embedded -dsn <dsn_name> -connect -user <username> -passwd <password> command. The <dsn_name> is the DSN in the db2dsdriver.cfg file you are testing the connection to. The <username> is the valid user ID that is used to connect to the target data source. The <password> is the valid password that is associated with the specified user ID.

Results

The db2cli validate -embedded -dsn <dsn_name> -connect -user <username> -passwd <password> command output displays the DSN value that you specified and the status of the connection test .

Example

The following command output shows a successful connection to the sampledsn DSN entry in the db2dsdriver.cfg file:
$ db2cli validate -embedded -dsn sampledsn –connect -user username -passwd password

...

Connection Section :
  ------------------------------------------------------------------
  Connecting to: sampledsn
  Connect Status: success
  End Connection Section
  ------------------------------------------------------------------

The validation completed.