Skip to Content

SAP HANA and JAVA: Consuming HANA “Information Models” using JAVA

Hello folks,

In this document, I will write the basic java program to connect to HANA Database and retrieve the information. I am going to consume the data model which I created using “graphical” editor of “Calculation View”. The target of this document is to make you understand the how we can connect to the models in HANA database with JAVA.

With this we can feel the power of united SAP and JAVA.

I have created a view called “CALC_VIEW” using graphic editor of calculation view as shown below:


In this view am trying to “Union” two tables “NYSE” and “NYSE_1” as you can see above. Now we have to launch eclipse IDE to write our java program.



import java.sql.*; 
    public class Connection 
           public static void main(String args[]) 
                  java.sql.Connection conn=DriverManager.getConnection("jdbc:odbc:HANA","userid","pwd"); 
                  Statement stmt = conn.createStatement(); 
                  ResultSet rs = stmt.executeQuery( "SELECT * FROM \"_SYS_BIC\".\"package/CALC_GRAPHIC\"" ); 
                   while( ) 
                         System.out.println( rs.getString(1)); 
                         System.out.println( rs.getString(2));  
                   rs.close() ; 
                   stmt.close() ; 
                   conn.close() ; 
                  catch(Exception e) 

See we can now see fetched the records from “CALC_GRAPHIC” view using this java program as shown below:


Thank your reading this blog 🙂 Do add your valuable suggestions to this document 🙂

You must be Logged on to comment or reply to a post.
    • Hello Thomas,


      Thank you for mentioning it. I missed to mention it. I have one more doubt. Will PHP work on top of HANA DB? Am able to connect but “SQL” statements not getting executed. Will these be available in future versions of HANA?



      Krishna Tangudu

      • We do want to open development to other platforms and techniques in the future.  At some point we will support the ODBC/JDBC drivers for 3rd party development. I really couldn’t say if it will work in PHP, however, because I don’t know what technical problems you are hitting.

  • Krishna


    Very nice… first of its kind blog….

    Now I got a question , I am getting this error




    which means , its not being able to dynamically load the jdbc driver ..


    Nor does your class path work for me ..


    Can you elaborate on the lines below , and perhaps give suggestions



    1.                   Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);   
    2.                   java.sql.Connection conn=DriverManager.getConnection(“jdbc:odbc:HANA”,“userid”,“pwd”);