ps0604
ps0604

Reputation: 1081

"Database not found" error while trying to connect to Hana with JDBC

This works fine:

GRANT SELECT ON SCHEMA DB1 TO USER1;

But when I try to connect in SQuirreL specifying the database:

enter image description here

I get the following error:

class com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: Cannot connect to jdbc:sap://10.194.19.20:39013/ [SAP DBTech JDBC: [2]: general error: database 'DB1' does not exist].

If I try to connect without specifying the database, it works fine and I can run selects with no problems on DB1. But I need to connect to Hana specifying the database in the URL. What's the problem and how to fix it?

Upvotes: 1

Views: 3566

Answers (2)

Eralper
Eralper

Reputation: 6622

Database and Schema are two different objects on a instance or tenant.

In a Database, database users have their own objects which are contained in Schemas So every database user can have a seperate schema. Schema object is mainly used for security. As in your sample code you are granting or allowing SELECT command on objects in DB1 schema to user USER1. (So USER1 can query objects of user DB1)

In database connection you shared with us, you need to provide the database name, not the schema user.

You can find the database name, on SAP GUI using System > Status menu options. You will see Database Data section. Use the value in "Name" textbox.

In general, every connection user is mapped to a default database user (so to a default schema on a database)

Upvotes: 1

ps0604
ps0604

Reputation: 1081

Instead of databaseName, use currentSchema

  "jdbc:sap://10.194.19.20:39013?currentSchema=DB1"

Upvotes: 0

Related Questions