Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tutorials/hana-clients-hdbsql/hana-clients-hdbsql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down
35 changes: 20 additions & 15 deletions tutorials/hana-clients-node/hana-clients-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand All @@ -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();
Expand All @@ -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
Expand Down
Binary file modified tutorials/hana-clients-node/node-query-connection-pool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tutorials/hana-cloud-alerts/hana-cloud-alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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;
Expand All @@ -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.
Expand Down
51 changes: 50 additions & 1 deletion tutorials/hana-dbx-hcc/hana-dbx-hcc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</food>
</breakfast_menu>' 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.

Expand All @@ -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
Expand Down
Binary file added tutorials/hana-dbx-hcc/result-viewer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.