SQLines Data - Configure and Troubleshoot Connection to IBM DB2

If you are going to connect to a localhost IBM DB2 database you do not need to setup any additional libraries to use SQLines Data tool as they are already supplied with IBM DB2 server.

If you need to connect to a remote IBM DB2 database, you need to have DB2 Runtime Client or IBM Data Server Driver Package installed in your system.

First check if you already have the IBM DB2 library:

  • Linux:
    • libdb2.so
    • For example, at:
    • /opt/ibm/db2/V11.1/lib64
    • /opt/ibm/db2/V11.1/lib32
    • /opt/ibm/db2/V10.5/lib
  • Windows:
    • db2cli64.dll (Windows 64-bit)
    • db2cli.dll
    • For example, at (Drive letter can be different):
    • C:\Program Files\IBM\SQLLIB\BIN

Configuring DB2 Connection on Linux

Before running sqldata command, add the DB2 library location to LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<db2_client_lib>

For example:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ibm/db2/V11.1/lib64

Troubleshooting DB2 Connection on Linux

If you get “Error allocating environment handle” error during connection to IBM DB on Linux host due to lack of permissions. Try ti run ./sqldata tool under sudo su - db2inst or other appropriate user from DB2ADMIN group.