2 Replies Latest reply: May 14, 2013 10:09 AM by user8835819 RSS

    [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed

    user8835819
      Please help!

      I have a problem with connecting from Oracle through unixODBC to a remote (physically) IBM DB2 z/OS mainframe. I am running Oracle Linux 6 64bit with Oracle DB 11.2r2 64bit . I have installed and configured DB2 Connect 64bit and are using unixODBC's ODBC connectivity to try and access the mainframe. I can do a connection using just DB2 Connect with no problem. Using the config files below, I can connect using iSQL with no problem. I can do a TNSPING on the IBM DB2 database with no problem. But when I try to connect using SQL Developer or SQLPLUS, I am getting the following error message:

      -----------------------------------------------------------------------------
      Error starting at line 1 in command:
      select sysdate from dual@db2u.xxxxxxxxxxxxx.com
      Error at Command Line:1 Column:26
      Error report:
      SQL Error: ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
      [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed {IM004}
      ORA-02063: preceding 2 lines from DB2U
      28500. 00000 - "connection from ORACLE to a non-Oracle system returned this message:"
      *Cause:    The cause is explained in the forwarded message.
      *Action:   See the non-Oracle system's documentation of the forwarded
      message.
      -----------------------------------------------------------------------------


      DB2U is the remote mainframe DB2 system. JHWIT1 is my local Linux server where Oracle is installed. DB2INST1 is the local DB2 Connect instance where DB2U is defined.
      Here are my config files:
      -----------------------------------------------------------------------------
      ODBC.INI

      [db2u]
      Description=DB2 Mainframe Database
      Driver=db2u
      DMEnvAttr=SQL_ATTR_UNIXODBC_ENVATTR={DB2INSTANCE=db2inst1}

      -----------------------------------------------------------------------------
      ODBCINST.INI

      [db2u]
      Description=IBM DB2 Adapter
      Driver=/home/db2inst1/sqllib/lib64/libdb2.so
      FileUsage=1
      DontDLClose=1
      dbalias=DB2U
      DB2SYSTEM=xxx.xxx.xxx.xxx
      ServerType=DB2MVS
      Nodetype=U
      Protocol=TCPIP
      Hostname=xxx.xxx.xxx.xxx
      Portnumber=450
      Security=0

      -----------------------------------------------------------------------------
      INITDB2U.ORA

      # This is a sample agent init file that contains the HS parameters that are
      # needed for the Database Gateway for ODBC

      #
      # HS init parameters
      #
      HS_FDS_CONNECT_INFO = db2u
      HS_FDS_TRACE_LEVEL = off
      HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
      HS_LANGUAGE=american_america.we8iso8859p1
      HS_FDS_TRANSACTION_ISOLATION=READ_UNCOMMITTED

      #
      # ODBC specific environment variables
      #
      set ODBCINI=/etc/odbc.ini


      #
      # Environment variables required for the non-Oracle system
      #
      set DB2INSTANCE = DB2INST1

      -----------------------------------------------------------------------------
      TNSNAMES.ORA

      db2u =
      (DESCRIPTION =
      (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = jhwit1.xxxxxxxxxx.com)(PORT = 1521))
      )
      (CONNECT_DATA =
      (SID = db2u)
      )
      (HS = OK)
      )

      -----------------------------------------------------------------------------
      LISTENER.ORA

      SID_LIST_LISTENER =
      (SID_LIST =
      (SID_DESC =
      (PROGRAM = dg4odbc)
      (ENVS=LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib:/home/dbinst1/sqllib/lib64:/usr/lib/64)
      (SID_NAME = db2u)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      )
      )

      -----------------------------------------------------------------------------
      DB2CLI.INI

      [COMMON]
      DiagPath=/home/db2inst1/sqllib/db2dump
      DiagLevel=4
      Trace=1
      TraceComm=1
      TraceErrImmediate=1
      TraceFlush=1
      TraceFlushOnError=1
      TraceTimeStamp=1
      TraceFileName=/home/db2inst1/sqllib/db2dump/db2trace.log
      TracePIDTID=1

      [db2u]
      Database = db2u
      Protocol = TCPIP
      Hostname = xxx.xxx.xxx.xxx
      ServiceName = 450

      -----------------------------------------------------------------------------
      Output from the ODBINST -j command:

      -bash-4.1$ odbcinst -j
      unixODBC 2.3.0
      DRIVERS............: /etc/odbcinst.ini
      SYSTEM DATA SOURCES: /etc/odbc.ini
      FILE DATA SOURCES..: /etc/ODBCDataSources
      USER DATA SOURCES..: /etc/odbc.ini
      SQLULEN Size.......: 8
      SQLLEN Size........: 8
      SQLSETPOSIROW Size.: 8
      -bash-4.1$
      -----------------------------------------------------------------------------

      I should mention that I have a connection to a local (physically) iSeries box that is working perfectly using iSeries software and unixODBC. It just seems to be a problem with going through DB2 Connect, unixODBC and Oracle DB directly. The Heterogeneous Connectivity is installed in the current Oracle HOME directory. Again, I can do iSQL with no problem and can do a TNSPING and get the right result. I just can't get the connection to work between DB2 Connect, unixODBC and Oracle DB. I have read numerous posts on this site and others that have the same error information but it always seems to be either unsolved or a different issue altogether. Please help.