1'use strict';
2const { PerformanceObserver, performance } = require('perf_hooks');
3var t0 = performance.now();
4var util = require('util');
5var hana = require('@sap/hana-client');
6
7var connOptions = {
8 serverNode: '@User1UserKey',
9 //serverNode: 'your host:your port',
10 //UID: 'USER1',
11 //PWD: 'Password1',
12 encrypt: 'true', //Must be set to true when connecting to SAP HANA Cloud
13 sslValidateCertificate: 'false', //Must be set to false when connecting
14 //to an SAP HANA, express edition instance that uses a self signed certificate.
15
16 //Below setting is used to specify where the trust store is
17 //ssltruststore: '/home/dan/.ssl/trust2.pem',
18
19 //Alternatively provide the contents of the certificate directly (DigiCertGlobalRootCA.pem)
20 //ssltruststore: '-----BEGIN CERTIFICATE-----MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQkCAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=-----END CERTIFICATE-----'
21};
22
23var connection = hana.createConnection();
24connection.connect(connOptions, function(err) {
25 if (err) {
26 return console.error(err);
27 }
28 var sql = 'select TITLE, FIRSTNAME, NAME from HOTEL.CUSTOMER;';
29 var rows = connection.exec(sql, function(err, rows) {
30 if (err) {
31 return console.error(err);
32 }
33 console.log(util.inspect(rows, { colors: false }));
34 var t1 = performance.now();
35 console.log("time in ms " + (t1 - t0));
36 connection.disconnect(function(err) {
37 if (err) {
38 return console.error(err);
39 }
40 });
41 });
42});
43