2685023 - How to connect HANA using Linux ODBC
Symptom
You would like to connect HANA system using ODBC connection in linux application server.
"Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental."
Environment
SAP HANA, platform edition
Resolution
- You have to install the unixODBC in your linux server. For how to install the unixODBC, you could have a reference on the Official website : http://www.unixodbc.org/
- To confirm that your unixODBC is installed, you could using command "odbcinst -j" to check the unixODBC version and Datasource information.

In the later steps, you will need to configure the SYSTEM DATA SOURCES file "/usr/local/etc/odbc.ini". - You have to install HANA client on your linux server. For how to install HANA client, please refer to guide from sap portal : Install the SAP HANA Client on UNIX, macOS, or Linux
After the HANA client is installed, go to the directory "/usr/sap/hdbclient" and find the driver "libodbcHDB.so", this means that HANA client is installed successfully.
- Configure the odbc.ini file "/usr/local/etc/odbc.ini" :
The format is like below:
[<DATABASE_NAME>]
servernode = <client_ip_address>:<sql_port>
#location of the unixODBC driver
driver = /usr/sap/<sid>/HDB<instance_number>/exe/libodbcHDB.so
description = <optional_description>
databasename = <your_database_alias>
My example as below :
-
Test the ODBC connection by following command:My example as below:
"isql <DATABASE_NAME> <user> <password>"

- In the last test connection, you may get error like the following:
# isql HSD <user> <password>
[ISQL]ERROR: Could not SQLConnect
In this case, you need to record the strace, using the following command"strace -f -eopen isql <DATABASE_NAME> <user> <password>"
In my case, you may get the following information by the strace:
<hostname>:~ # strace -f -eopen isql HSD <user> <password>
open("/etc/ld.so.cache", O_RDONLY) = 3open("/usr/local/lib/libodbc.so.2", O_RDONLY) = 3open("/usr/lib64/libltdl.so.7", O_RDONLY) = 3open("/lib64/libdl.so.2", O_RDONLY) = 3...
...
open("/root/.hdb/<hostname>/ODBC.shm", O_RDWR) = 3open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3open("/root/.hdb/<hostname>/SSFS_HDB.DAT", O_RDONLY) = 3open("/root/.hdb/<hostname>/SSFS_HDB.KEY", O_RDONLY) = -1 ENOENT (No such file or directory)open("/root/.odbc.ini", O_RDONLY) = 3open("/etc/odbc.ini", O_RDONLY) = -1 ENOENT (No such file or directory)open("/root/.odbc.ini", O_RDONLY) = 3open("/etc/odbc.ini", O_RDONLY) = -1 ENOENT (No such file or directory)[ISQL]ERROR: Could not SQLConnect
This means that the ODBC connection tries to find file "/etc/odbc.ini", but this does not exist. Actually, it is the file "/usr/local/etc/odbc.ini" where we maintained the ODBC connection. So you need to create a soft link to this file.ln -s /usr/local/etc/odbc.ini /etc/odbc.ini
After the symbolic link is created. this error will disappear. And the connection test will succeed.
Keywords
unixODBC, SUSE, ODBC Driver, odbc.ini, windows
作者:老应(weikui)
wechat: ywkonline
专注于SAP运维、升级、迁移
出处:http://www.cnblogs.com/weikui/
wechat: ywkonline
专注于SAP运维、升级、迁移
出处:http://www.cnblogs.com/weikui/
浙公网安备 33010602011771号