From:       To:      

Home > Documentation > IBM DB2

How to Connect to IBM DB2 Database

When Intelligent Converters software is installed on the same machine where IBM DB2 server is running, all is set and migration tool can be used right away. Otherwise, it is necessary to install and configure IBM client software. Basically there are two variations of DB2 client: IBM Data Server Driver/Runtime/Client and IBM CLI Driver.

Configure connection via IBM Data Server Driver/Runtime/Client

All these variations of DB2 client software include command line processor and can be configured by running the following DB2 command:

db2 catalog tcpip node nodename remote hostname server service_name


Local alias for the node to be cataloged.
Host name or IP address of the node where the target database resides. The maximum length of this parameter is 255 characters.
Service name (case sensitive!) or the port number of the server database manager instance. The maximum length of this parameter is 14 characters. If a service name is specified, the services file on the client is used to map the service name to a port number. The port number on the client and the server must match.

You can verify that all parameters were specified correctly by running the following statements:

db2 attach to nodename user username using password
db2 list applications
db2 detach


Name of the instance to attach.
Authentication identifier registered on the target DB2 server
Password for the user name

Configure connection via IBM DB2 CLI and ODBC drivers

There are two ways of configuring connection for IBM DB2 CLI and ODBC drivers - via settings in db2cli.ini or db2dsdriver.cfg configuration files. These files must be located in "cfg" subfolder of the driver installation. When connection settings are specified using both options, they are used in the following order:

This is example of db2cli.ini for connection to database "db1" running on host with opened port 56789:


And here is example of db2dsdriver.cfg for connection to database "sample" running on host with opened port 333:

    <dsn alias="myDSN" name="sample" host="" port="11111">
    <database name="sample" host="" port="333">
      <parameter name="CommProtocol" value="TCPIP"/>
      <parameter name="UID" value="username"/>

Have more questions? Contact us