SAP HANA hostname jdbc driver

10,322

Solution 1

Since you try to connect to a SAP HANA cloud instance, you cannot directly connect via an URL to the instance. Instead, you need to use a "Database Tunnel" as explained in the documentation for SAP HANA Cloud.

In SAP HANA Studio this is not required, because SAP HANA Studio automatically handles the database tunnel for you, when connecting to a cloud system.

  • Lars

Solution 2

I had faced the same issue and figured out a solution for that.

Please refer to the following link

HOW to connect to sap hana cloud instance thru jdbc Let me know if you have any questions.

Solution 3

You can download the SAP HANA SDK and use the included neo-tool to establish a tunnel-connection to your trial-instance:

neo open-db-tunnel 
   -h hanatrial.ondemand.com 
   -i <dbinstance> -a <p-accounttrial> -u <pusername>

This gives you something like this:

SAP HANA Cloud Platform Console Client

Password for your user:

Opening tunnel...

Tunnel opened.

Use these properties to connect to your schema:
  Host name        : localhost
  Database type    : HANAMDC
  JDBC Url         : jdbc:sap://localhost:30015/
  Instance number  : 00

Use any valid database user for the tunnel.
This tunnel will close automatically in 24 hours or when you close the shell.
Press ENTER to close the tunnel now.

Now you can connect to your cloud-database via your local tunnel on port 30015 and use the specified JDBC Url.

Share:
10,322
Admin
Author by

Admin

Updated on June 29, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to connect my java programme to the hana database. However, I am unable to do so because I have to connect my programme to the database through a url which I don't know. I registered for a hana trial online: https://account.hanatrial.ondemand.com. I created the account and the database and added it to the eclipse hana tools. How do I retrieve the url/servername/ipaddress that I have to use in place of HDB_URL

    I used this to connect the hana cloud system http://saphanatutorial.com/add-sap-hana-cloud-system-in-hana-studio-or-eclipse

    And I am trying to do this http://saphanatutorial.com/sap-hana-text-analysis-using-twitter-data/

    package com.saphana.startupfocus.util;
    
    import java.sql.*;
    import com.saphana.startupfocus.config.Configurations;
    
    public class HDBConnection {
    public static Connection connection = null;
    
    public static Connection getConnection() {
        try {
            if(null == connection){
                connection = DriverManager.getConnection(Configurations.HDB_URL,
                        Configurations.HDB_USER, Configurations.HDB_PWD);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }
    
    // Test HDB Connection 
    public static void main(String[] argv) throws ClassNotFoundException {
    
        connection = HDBConnection.getConnection();
        if (connection != null) {
            try {
                System.out.println("Connection to HANA successful!");
    
                Statement stmt = connection.createStatement();
                ResultSet resultSet = stmt
                        .executeQuery("Select 'helloworld' from dummy");
                resultSet.next();
                String hello = resultSet.getString(1);
                System.out.println(hello);
    
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    

    }