OpenESQL Error: Unable to load ODBC Driver/Driver Manager (RHEL 9, Visual Cobol 9, UnixODBC Driver Manager, Microsoft ODBC Driver 18 for SQL Server)

I have Visual COBOL 9, UnixODBC 2.3.9, Microsoft ODBC Driver 18 for SQL Server installed on RHEL 9.

odbcinst -j
unixODBC 2.3.9
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /xxxxxxx/odbc.ini

I have ODBCINI set to xxxxxxx/odbc.ini

LD_LIBRARY_PATH = :/opt/microfocus/VisualCOBOL/lib:/opt/microsoft/msodbcsql18/lib64:/usr/lib64

When I ran a simple COBOL program to connect to the database, I keep getting the following error:-

OpenESQL Error: Unable to load ODBC Driver/Driver Manager. Ensure that your
database environment is set correctly.
Connection to database failed:
Sqlcode = -0000010000
Sqlstate = IM001
Sqlerrmc =

Any help/suggestion will be appreciated.

Thanks!

  • 0  

    Just checking off the obvious thing...is your program compiled and running as 64 bit?

    Also, what is the contents of your odbcinst.ini and odbc.ini

  • 0 in reply to   

    Thanks  !

    I've checked, the program was compiled in 64 bit.
    cobmode
    Effective Default Working Mode: 64 bit

    Here's the content of

    ** odbcinst.ini
    [ODBC Driver 18 for SQL Server]
    Description=Microsoft ODBC Driver 18 for SQL Server
    Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
    UsageCount=1

    ** odbc.ini

    [ODBC Data Source]
    XXXXXXXXXX=Microsoft ODBC Driver 18 for SQL Server


    [XXXXXXXXXX]
    Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
    DESCRIPTION=Microsoft ODBC Driver 18 for SQL Server
    SERVER=xxxxxx,1437
    Database=xxxxxx
    TrustServerCertificate=yes

    I tested with PERL and Python, they all worked and were able to connect to the same database and retrieve data from it.

    But when I ran the COBOL program, I got the following:-
    OpenESQL Error: Unable to load ODBC Driver/Driver Manager. Ensure that your
    database environment is set correctly.
    Connection to database failed:
    Sqlcode = -0000010000
    Sqlstate = IM001
    Sqlerrmc =

  • 0   in reply to 

    What does your EXEC SQL CONNECT statement look like?

  • 0 in reply to   

    This is the code, thanks!

    display "SQLDSN_01" upon environment-name.
    accept Svr from environment-value.
    display "SQLDBUSR_01" upon environment-name.
    accept Usr from environment-value.
    display "SQLDBPSW_01" upon environment-name.
    accept Pass from environment-value.

    string
    Usr delimited space
    "." delimited size
    Pass delimited space
    into Usr-Pass

    exec sql
    connect to :Svr user :Usr-Pass
    end-exec

  • 0   in reply to 

    I was able to confirm this working with version 9.0 on RHEL 9.1 with SQL Server driver 18.0

    /etc/odbcinst.ini:

    [ODBC Driver 18 for SQL Server]
    Description=Microsoft ODBC Driver 18 for SQL Server
    Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
    UsageCount=1

    /etc/odbc.ini:

    [MyDB]
    Driver = ODBC Driver 18 for SQL Server
    Server = tcp:mysqlserverhost,1433
    Encrypt= No

    EXEC SQL
    CONNECT TO 'MyDB' user 'myuser.mypwd'
    END-EXEC

    My program is compiled with the OpenESQL pre-processor using the following directive beginning in col 7 (one of several ways to set this)

    $set sql(dbman=odbc)

    I have Encrypt set to No in odbc.ini for my D Source, because I don't have SSL or certificates setup with SQL Server.

  • 0 in reply to   

    Thanks again  !

    My program was compiled with $set sql(dbman=odbc), but still getting the same error.

    May I know what is set in your LD_LIBRARY_PATH variable? 

  • 0   in reply to 

    LD_LIBRARY_PATH=/opt/microfocus/EnterpriseDeveloper/lib:/opt/microsoft/msodbcsql18/lib64

    I'm using Enterprise Developer, but the underlying core COBOL and ESQL technology is the same

  • 0 in reply to   

    Thanks a lot  ! I'll review my installation and configuration again.

  • Verified Answer

    +1   in reply to 

    I did notice you have unixODBC 2.3.9 as your driver manager. Is that the default odbc driver manager that was present prior to installing the SQL Server driver? If so, you should uninstall any unixODBC driver manager package first (possibly was installed with the OS), and then install the SQL Server driver, tools, etc.

    Mine is unixODBC 2.3.11

  • 0 in reply to   

    Yes, it was present prior to the installation of the SQL Server driver.  Thanks for the suggestion!  Will uninstall them both, then install SQL Server driver.