將 Node.js 與 SAP HANA 系統整合
您可以使用 Node.js 向 HANA 資料庫插入資料。您還可以透過 JDBC 驅動程式連線到 SAP HANA 資料庫。
要透過 JDBC 連線,您需要安裝 JDBC 驅動程式 ngdbc.jar。該驅動程式作為 SAP HANA 客戶端安裝的一部分安裝。可以在以下位置找到 Ngdbc.jar 檔案 -
C:\Program Files\sap\hdbclient\ on Windows platforms /usr/sap/hdbclient/ on Linux and UNIX platforms
接下來,將 ngdb.jar 新增到類路徑中,編寫 Java 程式連線到資料庫並執行 SQL 命令。
jdbc:sap://myServer:30015/?autocommit=false
您還可以透過新增其他主機來新增一個或多個故障轉移伺服器。
示例
以下是連線 SAP HANA 伺服器的示例 -
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!");
}
}
}
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP