On 04/11/2018 01:20 PM, karthik kumar wrote:
This is the error we see in the ODBC trace log

             Environment = 0x556f874716a0
             Environment = 0x556f874716a0
             Attribute = SQL_ATTR_ODBC_VERSION
             Value = 0x3
             StrLen = 0
             Handle Type = 2
             Input Handle = 0x556f874716a0
             Output Handle = 0x556f874f2000
             Connection = 0x556f874f2000
             Window Hdl = (nil)
            Str In = [database=SAMPLE;DRIVER=SAMPLE;UID=db2inst1;PWD=********][length = 55 (SQL_NTS)]
             Str Out = 0x7ffd31cf8b60
             Str Out Max = 1024
             Str Out Ptr = 0x7ffd31cf8b3c
             Completion = 1
         UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

        DIAG [08001] [IBM][CLI Driver] SQL30081N  A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS".  Location where the error was detected: "::1".  Communication function detecting the error: "connect".  Protocol specific error code(s): "99", "*", "*".  SQLSTATE=08001

Protocol specific error code(s): "99":


EADDRNOTAVAIL 99 The specified hostname or IP address is not available from the local machine.

Looks to me like it is not finding your server IP and is trying IPv6 localhost with port 5000 and not finding it.

More comments below.


The trouble is, we are not convinced of the root cause, as using isql we can connect to db2 using the same account.

Env details

Db2 server on a docker container on my laptop: IP address
Db2 client where postgres server is installed is on a different container.  IP address:

Output of db2 list node directory

Node 2 entry:

  Node name                      = MYDB3
  Comment                        =
  Directory entry type           = LOCAL
  Protocol                       = TCPIP
  Hostname                       =
  Service name                   = 50000

output of db2 list db directory

Database alias                       = SAMPLE
  Database name                        = SAMPLE
  Node name                            = MYDB3
  Database release level               = 14.00
  Comment                              =
  Directory entry type                 = Remote
  Catalog database partition number    = -1
  Alternate server hostname            =
  Alternate server port number         =

So you changed settings below.

What happened to UID AND PWD?

Also I would simplify and get rid of in odbc.ini:


and in odbcinst.ini:


Also in odbcinst.init I would rename the section header from SAMPLE to DB2 and Driver in odbc.ini to DB2 Helps with identifying what you are actually using.

Did you also change the FOREIGN SERVER/USER MAPPING settings and if so to what?

$ cat /etc/odbc.ini
Description = DB2 remote SAMPLE Database
Driver = SAMPLE
servername =
system = MYDB3
username = db2inst1
password = db2inst1
port = 50000
Debug = 1
Commlog = 1

$ cat /etc/odbcinst.ini
Instance       =  MYDB3
Description     = DB2 ODBC Driver
Driver          = /home/db2inst1/sqllib/lib64/libdb2.so
CommLog         = 1
FileUsage       = 1
#DontDLClose    = 1

Adrian Klaver

Reply via email to