Skip to main content

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!


#VisualCOBOL
#unixODBC
#mssql

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!


#VisualCOBOL
#unixODBC
#mssql

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


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

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 =


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 =

What does your EXEC SQL CONNECT statement look like?


What does your EXEC SQL CONNECT statement look like?

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


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

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.


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.

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? 


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? 

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


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

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


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

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


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

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.


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.

I'm sure you have this...but just as a reference. I've always made sure there was no other driver manager installed

Installing the Driver Manager - ODBC Driver for SQL Server | Microsoft Learn


I'm sure you have this...but just as a reference. I've always made sure there was no other driver manager installed

Installing the Driver Manager - ODBC Driver for SQL Server | Microsoft Learn

Thanks! Will take note of that! 🙂


Thanks! Will take note of that! 🙂

Good new! As you suggested, I uninstalled unixODBC and SQL Server driver, then just installed SQL Server driver which also install unixODBC as a dependency.  And it works now! 

Thank you so much  !  Thanks for your patience and expertise! 


Good new! As you suggested, I uninstalled unixODBC and SQL Server driver, then just installed SQL Server driver which also install unixODBC as a dependency.  And it works now! 

Thank you so much  !  Thanks for your patience and expertise! 

Happy to hear it is now working!