Skip to Content

Connection between Hana DB and JAVA using JDBC - SAP HANA Cloud Platform

Hey Guys, i have a problem.

I wanted to connect to a HANA DB via JDBC using the sample of the SAP SDK.

This worked with the following sql statement: .prepareStatement("SELECT ID, FIRSTNAME, LASTNAME FROM T_PERSONST")

This worked.

Now i want to connect my Java Application with another scheme. Which SQL statement do I have to use? I tried the following:

.prepareStatement("select * from 'DQANALYSE'.'DataPrototypeNW.model::dqmodel.persons'");

.prepareStatement("select * from .'DataPrototypeNW.model::dqmodel.persons'");

.prepareStatement("select * from 'dqmodel.persons'");

.prepareStatement("select * from DQANALYSE.DataPrototypeNW.model::dqmodel.persons");

.prepareStatement("select * from DataPrototypeNW.model::dqmodel.persons");

.prepareStatement("select * from dqmodel.persons");

None of these statements worked out for me. Can somebody help me?

Thank you


Add comment
10|10000 characters needed characters exceeded

  • Hi Niklas,

    What is the error message?

    A typical issue is missing schema authorization. Are you sure you are connecting with a user that is allowed to perform select statements on such schemas?


  • Get RSS Feed

1 Answer

  • Apr 24, 2018 at 04:22 PM

    Hi Niklas,

    In SAP HANA, the quote character for identifiers is the double quote ". Without quotes, the identifiers are basically converted to upper case.

    So writing:

    select * from dqmodel.persons

    Is interpreted as:

    select * from DQMODEL.PERSONS

    I assume that your schema is called "DQANALYSE" and the table name is "DataPrototypeNW.model::dqmodel.persons" (Looking at the way your table name is constructed, I guess you used a CDS model file called "dqmodel" located in the package "DataPrototypeNW.model"). Based on these assumptions, your query should look like so:

    .prepareStatement("select * from \"DQANALYSE\".\"DataPrototypeNW.model::dqmodel.persons\"");


    Add comment
    10|10000 characters needed characters exceeded