Skip to Content
avatar image
Former Member

connecting HANA using JDBC

Hi All,

I am trying connecting HANA using JDBC. My HANA instance is on "SAP HANA cloud platform" (freeware for trial).

To connect hana instance using eclipse I used landscape host as https://hanatrial.ondemand.com

What should I put in below connection information for <YOUR SAP HANA IP> ?

java.sql.Connection conn= java.sql.DriverManager.getConnection("jdbc:sap://<YOUR SAP HANA IP>:30015","<YOUR SAP HANA USER>","<YOUR PASSWORD>");

I tried giving jdbc:sap://hanatrial.ondemand.com:30015, however not succeeded to connect.

Regards,

Sagar.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Jan 06, 2015 at 11:53 PM

    hi Sagar,

    are you trying to establish jdbc connection so that you can hook up a 3rd party tool to your hcp database?

    if so you can connect to your hcp via the command line tool which will give you the jdbc information needed for consumption by another tool. this information is good for 24 hours as the password is valid for up to that time unless a new connection is established.

    if you go to the hana academy hcp playlist then have a look at the "connecting to a schema using the command line tool" video as well as the "connecting to an hcp schema from lumira". the first video will show you how to get the necessary info from the command line and the second one will show you how to connect via jdbc using lumira which will hopefully help you out.

    -jamie


    Untitled.jpg (91.5 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 07, 2015 at 03:50 PM

    Sagar,

    if you prefer to read up this information and to get additional details about automating the access via the DB tunnel, please have a look at the Remote Database Access section of the official SAP HANA Cloud Documentation.

    Best regards,

    Oliver

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 05, 2015 at 12:24 PM

    hi Sagar,

    Please use this code.

    Class.forName("com.sap.db.jdbc.Driver");

    java.sql.Connection conn= java.sql.DriverManager.getConnection("jdbc:sap://<YOUR SAP HANA IP>:30015","<YOUR SAP HANA USER>","<YOUR PASSWORD>");

    Statement stmt = conn.createStatement();

    ResultSet rs = stmt.executeQuery( "SELECT * FROM \"_SYS_BIC\".\"tutorials.java/CALC_GRAPHIC\"" );

    SimpleDateFormat sd = new SimpleDateFormat("dd.MM.yyyy");

    while( rs.next() )

    {

    System.out.print( rs.getString(1) + " | ");

    System.out.print( rs.getString(2) + " ");

    System.out.print( rs.getString(3) + " | ");

    System.out.print( sd.format(rs.getTimestamp(4)) + " | ");

    System.out.println( rs.getString(5) );

    }

    rs.close() ;

    stmt.close() ;

    conn.close() ;

    Add comment
    10|10000 characters needed characters exceeded