cancel
Showing results for 
Search instead for 
Did you mean: 

connect to HANA Database via ODBC

marebo
Explorer

Hello,

I'm currently facing a problem when connecting to HANA database via ODBC. It works properly when I omit Parameter "DATABASENAME". But when I try to Connect using this Parameter, I always receive a "General error; 2 General error: database '<dbname>' does not exist. I've alread read about a similar problem, where incorrect port-no. seemed to cause the Problem. Well, I'm connecting to a multi-tenant DB and use 30015 as port-no. How can I retrieve proper port?

Accepted Solutions (0)

Answers (3)

Answers (3)

marebo
Explorer

Hello Bartosz,

Thank you very much for your soon Response!

I checked the blog post and run SQL-Statement on our Server. It returned

So, in my opinion port-no 30015 is appropriate for ODBC-Connectstring:

DRIVER={HDBODBC32};UID=SYSTEM;PWD=<pwd>;SERVERNODE=srvsbodev10:30015;DATABASENAME=SBODEMODE

As this doesn't work, I also tried port-no 39013 (System tenant) which also failed.

I'm wondering, why using port 30015 works when ommiting DATABASENAME-Option. If port-no was not correct, it should work at all

lbreddemann
Active Contributor
0 Kudos

You are confusing the database name with the server name here. Is this even a multi tenant db installation?

Could it be that you used to use MS SQL Server systems?

marebo
Explorer
0 Kudos

You're right, I'm used to SQL Server. I've tried out some various Connection strings and found that I used a catalog name instead of the database name. After changing that, I can connect to HANA-DB now. There's one problem with that: Unlike SQL Server I cannot determine an initial catalog. As none of the SQL-Statements used in our program references tables in way like "<catalog>.<table>", it would be very helpful to have an option to dertermine a Default catalog I need to use. Otherwise I'd have to change tons of queries.

lbreddemann
Active Contributor
0 Kudos

The "initial catalog" in SAP HANA is the database users own schema.

You can set a different current schema when connecting to the database via the CURRENTSCHEMA parameter or, once connected, change the current schema via SET SCHEMA <SCHEMA NAME>.

There's no need to change your application code for that.

BJarkowski
Active Contributor

Hello ,

please check folowing blog post:

https://blogs.sap.com/2017/12/04/hey-sap-hana-express-edition-any-idea-whats-your-sql-port-number/

It clearly says how to retrieve the port numbers for multitenant databases.

lbreddemann
Active Contributor
0 Kudos

connect to the SystemDB via port 3<instance no>13 plus the DATABASENAME. That will trigger the SAP HANA client to query the SystemDB for the actual port of the database.

marebo
Explorer
0 Kudos

Tried out "...SERVERNODE=srvsbodev10:30013;DATABASENAME=SBODEMODE"

Exception is "ERROR [08S01] [SAP AG][LIBODBCHDB32 DLL][HDBODBC32] Communication link failure;-10709 Connect failed (connect timeout expired)"