Connect To HANA DB Using Java

03 November 2017 - 1054 views
Connecting to a HANA system using Java requires the JDCB ngdbc.jar driver. This driver comes as part of the HANA Studio installation. You can also download it when installing HANA Express using the download manager.

Listing 1 below shows a sample connection code.

Listing 1

import java.sql.*;

class Example{

    public static void main(String args[]){

        try {                  
            Connection connection = DriverManager.getConnection(
            "jdbc:sap://host:30015""USER""PASSWORD"); 
                System.err.println("Connected");
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }
}