- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Integrate node.js with SAP HANA system
You can insert data into HANA database using node.js. You can also connect to SAP HANA database via JDBC driver.
To connect via JDBC, you need to install JDBC driver ngdbc.jar. This driver is installed as part of SAP HANA client installation. Ngdbc.jar file is available at this location −
C:\Program Files\sap\hdbclient\ on Windows platforms /usr/sap/hdbclient/ on Linux and UNIX platforms
Next is to add ngdb.jar to the classpath and write a Java program to connect to a database and execute SQL command.
jdbc:sap://myServer:30015/?autocommit=false
You can also add one or more failover servers by adding additional hosts.
Example
Following is an example of connecting SAP HANA Server −
import java.sql.*; public class jdemo { public static void main(String[] argv) { Connection connection = null; try { connection = DriverManager.getConnection( "jdbc:sap://myhdb:30015/?autocommit=false",uname,mypwrd); } catch (SQLException e) { System.err.println("Connection Failed. User/Passwd Error?"); return; } if (connection != null) { try { System.out.println("Connection to HANA successful!"); Statement stmt = connection.createStatement(); ResultSet resultSet = stmt.executeQuery("Select 'hello world' from dummy"); resultSet.next(); String hello = resultSet.getString(1); System.out.println(hello); } catch (SQLException e) { System.err.println("Query failed!"); } } } }
Advertisements