diff --git a/tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md b/tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md index 710529c904..66bd0e3458 100644 --- a/tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md +++ b/tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md @@ -157,7 +157,7 @@ This step demonstrates how to connect to a SAP HANA instance using [HDBSQL](http ### Create user and schema -This step creates a user named `USER1`. `USER1` will be the owner of the tables that will be created in a subsequent steps and will be used to connect to the database. +This step creates two users and a schema. `USER1` will be the owner of the tables that will be created in a subsequent steps and will be used to connect to the database. On Linux or a Mac, turn off page by page scroll output. Also, consult the `-j` `hdbsql` option. This enables multiple commands to be pasted at one time and does not require each result to be exited by pressing q. @@ -169,7 +169,7 @@ On Linux or a Mac, turn off page by page scroll output. Also, consult the `-j` ```SQL CREATE USER USER1 PASSWORD Password1 no force_first_password_change; - CREATE USER USER2 PASSWORD Password2 no force_first_password_change; --Used in the entity framework tutorial + CREATE USER USER2 PASSWORD Password2 no force_first_password_change; --Used in the Node.js connection pool example and the entity framework tutorial. ``` >The end of this tutorial contains SQL statements to delete the user, schema and objects created. This may be helpful if you wish to recreate the sample dataset used in this tutorial. diff --git a/tutorials/hana-clients-node/hana-clients-node.md b/tutorials/hana-clients-node/hana-clients-node.md index f011fa9ada..4f6f87a311 100644 --- a/tutorials/hana-clients-node/hana-clients-node.md +++ b/tutorials/hana-clients-node/hana-clients-node.md @@ -286,8 +286,6 @@ Node.js packages are available using [NPM](https://www.npmjs.com/), which is the ``` ### Create a synchronous app that uses a connection pool - - Connection pooling can improve performance when making multiple, brief connections to the SAP HANA database. The following sample makes two connections one after another without using a connection pool and then using a connection pool. It demonstrates how the time taken to make a connection with a connection retrieved from a pool is significantly shorter. 1. Open a file named `nodeQueryConnectionPool.js` in an editor. @@ -324,6 +322,7 @@ Connection pooling can improve performance when making multiple, brief connectio poolCapacity: 10, //max # of connections in the pool waiting to be used maxConnectedOrPooled: 20, //max # of connections in the pool + the # of connections in use pingCheck: false, + allowSwitchUser: true, //requires SAP HANA Client 2.17 maxPooledIdleTime: 3600, //1 hour (in seconds) } @@ -332,38 +331,42 @@ Connection pooling can improve performance when making multiple, brief connectio queryTable(false, "1st Run"); queryTable(false, "2nd Run"); queryTable(true, "1st Run"); - //console.log(pool.clear()); queryTable(true, "2nd Run"); + queryTable(true, "3rd Run", true); //change user console.log("Connections in use :" + pool.getInUseCount()); console.log("Connections in the pool :" + pool.getPooledCount()); //Creates two connections either using connection pooling or not //Displays timing information - function queryTable(usePool, run) { + function queryTable(usePool, run, user2) { var t0 = performance.now() var connection = null; - if (!usePool) { - connection = hana.createConnection(); - connection.connect(connOptions); - var t1 = performance.now(); - } - else { + if (usePool) { //use the connection pool var t0 = performance.now(); if (pool === null) { pool = hana.createPool(connOptions, poolProperties); //create a connection pool } - - connection = pool.getConnection(); //get a connection from the pool + if (user2) { //example of changing the user + connection = pool.getConnection('USER2','Password3'); //Requires 2.17 of the SAP HANA Client + } + else { + connection = pool.getConnection(); //get a connection from the pool + } + var t1 = performance.now(); + } + else { //don't use the connection pool + connection = hana.createConnection(); + connection.connect(connOptions); var t1 = performance.now(); } var t2 = performance.now(); - var sql = 'select TITLE, FIRSTNAME, NAME from HOTEL.CUSTOMER;'; + var sql = 'select CURRENT_USER FROM DUMMY;'; var result = connection.exec(sql); var t3 = performance.now(); var t4 = performance.now(); - //console.log(util.inspect(result, { colors: false })); + console.log(util.inspect(result, { colors: false })); var t5 = performance.now(); var t6 = performance.now(); @@ -386,9 +389,11 @@ Connection pooling can improve performance when making multiple, brief connectio node nodeQueryConnectionPool.js ``` + Notice below that the time taken to establish a connection is approx 900 ms which but becomes almost instantaneous when the connection pool is used or about 85 ms when a connection from the pool requires changing the user. + ![Running nodeQueryConnectionPool.js](node-query-connection-pool.png) - See [Node.js Connection Pooling](https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/e252ff9b2cb44dd9925901e39025ce77.html) for additional details. The example above uses a new API that was added in the 2.13 release and documented in the 2.14 release. This new API provides a more direct way to interact with the connection pool. + See [Node.js Connection Pooling](https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/e252ff9b2cb44dd9925901e39025ce77.html) for additional details. The example above uses a new API that was added in the 2.17 release. ### Create an asynchronous app that uses callbacks diff --git a/tutorials/hana-clients-node/node-query-connection-pool.png b/tutorials/hana-clients-node/node-query-connection-pool.png index f4589b834d..10800a09e4 100644 Binary files a/tutorials/hana-clients-node/node-query-connection-pool.png and b/tutorials/hana-clients-node/node-query-connection-pool.png differ diff --git a/tutorials/hana-cloud-alerts/hana-cloud-alerts.md b/tutorials/hana-cloud-alerts/hana-cloud-alerts.md index 1d8e36c6c8..443069d077 100644 --- a/tutorials/hana-cloud-alerts/hana-cloud-alerts.md +++ b/tutorials/hana-cloud-alerts/hana-cloud-alerts.md @@ -219,8 +219,9 @@ The following instructions will show how to view a triggered SAP HANA database a ### Trigger an alert in SAP HANA Cloud data lake +The following instructions show one example of triggering the [data lake locked user event](https://help.sap.com/viewer/5967a369d4b74f7a9c2b91f5df8e6ab6/Cloud/en-US/11b9ef0ed4dd4e1dae36147fe313b381.html). The alert will be triggered when a user attempts to log in **after** the user account has been locked because an incorrect password has been provided too many times. -The following instructions show one example of triggering the [data lake locked user event](https://help.sap.com/viewer/5967a369d4b74f7a9c2b91f5df8e6ab6/Cloud/en-US/11b9ef0ed4dd4e1dae36147fe313b381.html). The alert will be triggered when a user attempts to log in after the user account has been locked because an incorrect password has been provided too many times. +>This alert is not available in trial accounts. 1. In an SAP HANA database explorer that is connected to a **data lake**, execute the following SQL to create a login policy and a new user. @@ -246,8 +247,9 @@ The following instructions show one example of triggering the [data lake locked ![Locked user2](data-lake-user-locked.png) +3. Attempt to connect one more time after the account has been locked (4th time) to trigger the alert. -3. Additional details about users can be seen by calling the procedure `sa_get_user_status`. The user can be unlocked using by resetting the login policy. +4. Additional details about users can be seen by calling the procedure `sa_get_user_status`. The user can be unlocked using by resetting the login policy. ```SQL CALL sa_get_user_status; @@ -258,8 +260,6 @@ The following instructions show one example of triggering the [data lake locked The tutorial [Monitor a Standalone Data Lake in SAP HANA Cloud](hana-cloud-hdl-getting-started-4) may also be of interest as it demonstrates the data lake Relational Engine monitoring views. - - ### Set up email notification when an alert occurs The SAP Business Technology Platform (BTP) includes a service called the SAP Alert Notification service (ANS) that provides a common way for other services or applications running in the SAP BTP to send out notifications such as an email, a post to a Microsoft Teams or Slack channel, the creation of a ticket in `ServiceNow`, or a webhook to send events to any Internet REST endpoint. The SAP HANA Cloud database and data lake pass on events to the SAP ANS when an alert is triggered. diff --git a/tutorials/hana-dbx-hcc/hana-dbx-hcc.md b/tutorials/hana-dbx-hcc/hana-dbx-hcc.md index 136156c8b2..b092ec6ac8 100644 --- a/tutorials/hana-dbx-hcc/hana-dbx-hcc.md +++ b/tutorials/hana-dbx-hcc/hana-dbx-hcc.md @@ -114,6 +114,55 @@ This step demonstrates how to execute a SQL query and view query results, messag >The history is not persisted across browser reloads. +5. Execute the following SQL statements. + + ```SQL + SELECT HEXTOBIN ('48656C6C6F20776F726C64') BINARY_EXAMPLE FROM DUMMY; + + SELECT '{ + "name":"John", + "age":30, + "cars": { + "car1":"Ford", + "car2":"BMW", + "car3":"Fiat" + } + }' AS JSON_EXAMPLE + FROM DUMMY; + + SELECT ' + + + Strawberry Belgian Waffles + $7.95 + + Light Belgian waffles covered with strawberries and whipped cream + + 900 + + + French Toast + $4.50 + + Thick slices made from our homemade sourdough bread + + 600 + + + Homestyle Breakfast + $6.95 + + Two eggs, bacon or sausage, toast, and our ever-popular hash browns + + 950 + + ' XML_EXAMPLE FROM DUMMY + ``` + + Double tapping on a result will open a result viewer. + + ![SQL results](result-viewer.png) + ### A few things to note The SQL console within SAP HANA Cloud Central appears similar to the one within the SAP HANA database explorer but there are some differences. @@ -128,7 +177,7 @@ The SQL console within SAP HANA Cloud Central appears similar to the one within * SQL parsing to detect potential errors * Code completion of schema objects * SQL formatting - * SQL viewers for HTML, XML, JSON, binary, and spatial + * SQL viewers for spatial * Results can be downloaded in a CSV * Ability to run statements in the background * Ability to run statements against multiple instances diff --git a/tutorials/hana-dbx-hcc/result-viewer.png b/tutorials/hana-dbx-hcc/result-viewer.png new file mode 100644 index 0000000000..a73f516d89 Binary files /dev/null and b/tutorials/hana-dbx-hcc/result-viewer.png differ