Skip to content

Commit 0f118cf

Browse files
committed
Update examples so Windows can have Oracle client libs in PATH
1 parent 2ef8901 commit 0f118cf

Some content is hidden

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

65 files changed

+578
-260
lines changed

examples/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";

examples/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";

examples/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";

examples/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";

examples/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;

examples/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

examples/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() {

examples/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() {

examples/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

examples/cqn2.js

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

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

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

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

0 commit comments

Comments
 (0)