Skip to content

Commit 0238d0e

Browse files
authored
Update examples for node-oracledb 5.3 (oracle-samples#178)
Signed-off-by: Christopher Jones <christopher.jones@oracle.com>
1 parent 283863c commit 0238d0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+584
-264
lines changed

javascript/node-oracledb/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Node-oracledb Examples
22

33
This directory contains [node-oracledb](https://www.npmjs.com/package/oracledb)
4-
examples. Documentation is [here
5-
](https://oracle.github.io/node-oracledb/doc/api.html).
4+
examples. Documentation is
5+
[here](https://oracle.github.io/node-oracledb/doc/api.html).
66

77
To run the examples:
88

@@ -23,13 +23,15 @@ for example:
2323
- In a terminal window, set the environment variable `NODE_ORACLEDB_PASSWORD` to
2424
the value of your database password.
2525

26-
- Review the samples and then run them like:
26+
- Review the samples and then run them individually. For example, to see what
27+
the file `example.js` does, use:
2728

2829
```
2930
node example.js
3031
```
3132

32-
- After running example, the demonstration objects can be dropped with `demodrop.js`:
33+
- After running examples, the demonstration objects can be dropped with
34+
`demodrop.js`:
3335

3436
```
3537
node demodrop.js

javascript/node-oracledb/aqmulti.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
*****************************************************************************/
3232

33+
const fs = require('fs');
3334
const oracledb = require('oracledb');
3435
const dbConfig = require('./dbconfig.js');
3536

@@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js');
3839
// the system library search path must always be set before Node.js is started.
3940
// See the node-oracledb installation documentation.
4041
// If the search path is not correct, you will get a DPI-1047 error.
41-
if (process.platform === 'win32') { // Windows
42-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
43-
} else if (process.platform === 'darwin') { // macOS
44-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
42+
let libPath;
43+
if (process.platform === 'win32') { // Windows
44+
libPath = 'C:\\oracle\\instantclient_19_12';
45+
} else if (process.platform === 'darwin') { // macOS
46+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
47+
}
48+
if (libPath && fs.existsSync(libPath)) {
49+
oracledb.initOracleClient({ libDir: libPath });
4550
}
4651

4752
const queueName = "DEMO_RAW_QUEUE";

javascript/node-oracledb/aqobject.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*
3232
*****************************************************************************/
3333

34+
const fs = require('fs');
3435
const oracledb = require('oracledb');
3536
const dbConfig = require('./dbconfig.js');
3637

@@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js');
3940
// the system library search path must always be set before Node.js is started.
4041
// See the node-oracledb installation documentation.
4142
// If the search path is not correct, you will get a DPI-1047 error.
42-
if (process.platform === 'win32') { // Windows
43-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
44-
} else if (process.platform === 'darwin') { // macOS
45-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
43+
let libPath;
44+
if (process.platform === 'win32') { // Windows
45+
libPath = 'C:\\oracle\\instantclient_19_12';
46+
} else if (process.platform === 'darwin') { // macOS
47+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
48+
}
49+
if (libPath && fs.existsSync(libPath)) {
50+
oracledb.initOracleClient({ libDir: libPath });
4651
}
4752

4853
const queueName = "ADDR_QUEUE";

javascript/node-oracledb/aqoptions.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
*****************************************************************************/
3232

33+
const fs = require('fs');
3334
const oracledb = require('oracledb');
3435
const dbConfig = require('./dbconfig.js');
3536

@@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js');
3839
// the system library search path must always be set before Node.js is started.
3940
// See the node-oracledb installation documentation.
4041
// If the search path is not correct, you will get a DPI-1047 error.
41-
if (process.platform === 'win32') { // Windows
42-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
43-
} else if (process.platform === 'darwin') { // macOS
44-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
42+
let libPath;
43+
if (process.platform === 'win32') { // Windows
44+
libPath = 'C:\\oracle\\instantclient_19_12';
45+
} else if (process.platform === 'darwin') { // macOS
46+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
47+
}
48+
if (libPath && fs.existsSync(libPath)) {
49+
oracledb.initOracleClient({ libDir: libPath });
4550
}
4651

4752
const queueName = "DEMO_RAW_QUEUE";

javascript/node-oracledb/aqraw.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
*****************************************************************************/
3232

33+
const fs = require('fs');
3334
const oracledb = require('oracledb');
3435
const dbConfig = require('./dbconfig.js');
3536

@@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js');
3839
// the system library search path must always be set before Node.js is started.
3940
// See the node-oracledb installation documentation.
4041
// If the search path is not correct, you will get a DPI-1047 error.
41-
if (process.platform === 'win32') { // Windows
42-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
43-
} else if (process.platform === 'darwin') { // macOS
44-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
42+
let libPath;
43+
if (process.platform === 'win32') { // Windows
44+
libPath = 'C:\\oracle\\instantclient_19_12';
45+
} else if (process.platform === 'darwin') { // macOS
46+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
47+
}
48+
if (libPath && fs.existsSync(libPath)) {
49+
oracledb.initOracleClient({ libDir: libPath });
4550
}
4651

4752
const queueName = "DEMO_RAW_QUEUE";

javascript/node-oracledb/blobhttp.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
*****************************************************************************/
3131

32+
const fs = require('fs');
3233
const url = require('url');
3334
const http = require('http');
3435
const oracledb = require('oracledb');
@@ -40,10 +41,14 @@ const demoSetup = require('./demosetup.js');
4041
// the system library search path must always be set before Node.js is started.
4142
// See the node-oracledb installation documentation.
4243
// If the search path is not correct, you will get a DPI-1047 error.
43-
if (process.platform === 'win32') { // Windows
44-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
45-
} else if (process.platform === 'darwin') { // macOS
46-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
44+
let libPath;
45+
if (process.platform === 'win32') { // Windows
46+
libPath = 'C:\\oracle\\instantclient_19_12';
47+
} else if (process.platform === 'darwin') { // macOS
48+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
49+
}
50+
if (libPath && fs.existsSync(libPath)) {
51+
oracledb.initOracleClient({ libDir: libPath });
4752
}
4853

4954
const httpPort = 7000;

javascript/node-oracledb/calltimeout.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
*****************************************************************************/
3131

32+
const fs = require('fs');
3233
const oracledb = require("oracledb");
3334
const dbConfig = require('./dbconfig.js');
3435

@@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js');
3738
// the system library search path must always be set before Node.js is started.
3839
// See the node-oracledb installation documentation.
3940
// If the search path is not correct, you will get a DPI-1047 error.
40-
if (process.platform === 'win32') { // Windows
41-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
42-
} else if (process.platform === 'darwin') { // macOS
43-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
41+
let libPath;
42+
if (process.platform === 'win32') { // Windows
43+
libPath = 'C:\\oracle\\instantclient_19_12';
44+
} else if (process.platform === 'darwin') { // macOS
45+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
46+
}
47+
if (libPath && fs.existsSync(libPath)) {
48+
oracledb.initOracleClient({ libDir: libPath });
4449
}
4550

4651
const dboptime = 4; // seconds the simulated database operation will take

javascript/node-oracledb/connect.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
'use strict';
3232

33+
const fs = require('fs');
3334
const oracledb = require('oracledb');
3435
const dbConfig = require('./dbconfig.js');
3536

@@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js');
3839
// the system library search path must always be set before Node.js is started.
3940
// See the node-oracledb installation documentation.
4041
// If the search path is not correct, you will get a DPI-1047 error.
41-
if (process.platform === 'win32') { // Windows
42-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
43-
} else if (process.platform === 'darwin') { // macOS
44-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
42+
let libPath;
43+
if (process.platform === 'win32') { // Windows
44+
libPath = 'C:\\oracle\\instantclient_19_12';
45+
} else if (process.platform === 'darwin') { // macOS
46+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
47+
}
48+
if (libPath && fs.existsSync(libPath)) {
49+
oracledb.initOracleClient({ libDir: libPath });
4550
}
4651

4752
async function run() {

javascript/node-oracledb/connectionpool.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
// running your application.
4343
// process.env.UV_THREADPOOL_SIZE = 4;
4444

45+
const fs = require('fs');
4546
const oracledb = require('oracledb');
4647
const dbConfig = require('./dbconfig.js');
4748

@@ -50,10 +51,14 @@ const dbConfig = require('./dbconfig.js');
5051
// the system library search path must always be set before Node.js is started.
5152
// See the node-oracledb installation documentation.
5253
// If the search path is not correct, you will get a DPI-1047 error.
53-
if (process.platform === 'win32') { // Windows
54-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
55-
} else if (process.platform === 'darwin') { // macOS
56-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
54+
let libPath;
55+
if (process.platform === 'win32') { // Windows
56+
libPath = 'C:\\oracle\\instantclient_19_12';
57+
} else if (process.platform === 'darwin') { // macOS
58+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
59+
}
60+
if (libPath && fs.existsSync(libPath)) {
61+
oracledb.initOracleClient({ libDir: libPath });
5762
}
5863

5964
async function init() {

javascript/node-oracledb/cqn1.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
*
3737
*****************************************************************************/
3838

39+
const fs = require('fs');
3940
const oracledb = require("oracledb");
4041
const dbConfig = require('./dbconfig.js');
4142

@@ -44,10 +45,14 @@ const dbConfig = require('./dbconfig.js');
4445
// the system library search path must always be set before Node.js is started.
4546
// See the node-oracledb installation documentation.
4647
// If the search path is not correct, you will get a DPI-1047 error.
47-
if (process.platform === 'win32') { // Windows
48-
oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' });
49-
} else if (process.platform === 'darwin') { // macOS
50-
oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' });
48+
let libPath;
49+
if (process.platform === 'win32') { // Windows
50+
libPath = 'C:\\oracle\\instantclient_19_12';
51+
} else if (process.platform === 'darwin') { // macOS
52+
libPath = process.env.HOME + '/Downloads/instantclient_19_8';
53+
}
54+
if (libPath && fs.existsSync(libPath)) {
55+
oracledb.initOracleClient({ libDir: libPath });
5156
}
5257

5358
dbConfig.events = true; // CQN needs events mode

0 commit comments

Comments
 (0)