While connecting to SQL from client application(running on linux server), using using ‘SQL Native client 11.0 (ODBC) driver for Linux’ we were getting following error message.
[root@axxxxxazureapi]# isql -v< DSN> <USERNAME> <PASSWORD>
[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
[ISQL]ERROR: Could not SQLConnect
In my case the issue is related with wrong installation path of the sqlncli dll. when we were trying to connect to SQL from Linux the application is trying to get the dll from a different path.
The best way to get the root cause is to take ODBC trace while issue is happening. It will give you more details about the failing API.
Before getting the trace check the UnixODBC version with following command:
odbcinst –j from linux command prompt and verified that unixODBC 2.3.0 (exactly that version, not older or newer) is installed.
Output is following:
$ odbcinst -j
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/odbcuser/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
How to get the ODBC trace:
The ODBC Driver for SQL Server on Linux supports tracing of ODBC API call entry and exit.
To trace your application behavior, first add the following line to the odbcinst.ini file:
Then start your application with strace. For example:
strace -t -f -o trace_out.txt executable
In place of executable just use the command that you are using to run your application. In our case it is like following.
strace -t -f -o trace_out.txt isql -v <DSN>< USERNAME> <PASSWORD>
Once you get the error check the trace file. It will give you more information about the connection failure. On that basis you can troubleshoot the issue.
In my case the path of sqlncli.dll is not found because the application is pointing to a different path and the sqlncli.dll was installed to a different location. After moving the file to that location our application was working fine.
Author : Mukesh(MSFT), Suport engineer, Microsoft
Reviewed by : Snehadeep(MSFT), SQL Developer Technical Lead, Microsoft
you'r using a .dll instead of an.so? are that possible? if so.
how did you do that ?