oracledb 6.6.0 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +2 -2
  2. package/build/Release/Linux_cmds.txt +972 -0
  3. package/build/Release/oracledb-6.7.1-darwin-arm64.node +0 -0
  4. package/build/Release/oracledb-6.7.1-darwin-arm64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-6.7.1-darwin-x64.node +0 -0
  6. package/build/Release/oracledb-6.7.1-darwin-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.7.1-js-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.7.1-linux-arm64.node +0 -0
  9. package/build/Release/oracledb-6.7.1-linux-arm64.node-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-6.7.1-linux-x64.node +0 -0
  11. package/build/Release/oracledb-6.7.1-linux-x64.node-buildinfo.txt +1 -0
  12. package/build/Release/oracledb-6.7.1-win32-x64.node +0 -0
  13. package/build/Release/oracledb-6.7.1-win32-x64.node-buildinfo.txt +1 -0
  14. package/examples/example.js +5 -5
  15. package/lib/configProviders/azure.js +26 -15
  16. package/lib/configProviders/base.js +23 -37
  17. package/lib/configProviders/ociobject.js +53 -45
  18. package/lib/connection.js +75 -3
  19. package/lib/errors.js +26 -14
  20. package/lib/impl/aqQueue.js +2 -1
  21. package/lib/impl/base.js +45 -0
  22. package/lib/impl/connection.js +53 -0
  23. package/lib/impl/lob.js +2 -1
  24. package/lib/impl/pool.js +15 -0
  25. package/lib/impl/resultset.js +2 -1
  26. package/lib/impl/sodaCollection.js +2 -1
  27. package/lib/impl/sodaDatabase.js +2 -1
  28. package/lib/impl/sodaDocCursor.js +2 -1
  29. package/lib/impl/sodaOperation.js +2 -1
  30. package/lib/lob.js +3 -2
  31. package/lib/oracledb.js +221 -36
  32. package/lib/pool.js +14 -5
  33. package/lib/settings.js +1 -0
  34. package/lib/thin/connection.js +150 -91
  35. package/lib/thin/dbObject.js +13 -4
  36. package/lib/thin/pool.js +3 -0
  37. package/lib/thin/protocol/constants.js +1 -1
  38. package/lib/thin/protocol/messages/auth.js +12 -6
  39. package/lib/thin/protocol/messages/base.js +3 -0
  40. package/lib/thin/protocol/messages/sessionRelease.js +1 -0
  41. package/lib/thin/protocol/messages/withData.js +6 -13
  42. package/lib/thin/protocol/protocol.js +23 -0
  43. package/lib/thin/sqlnet/connStrategy.js +12 -3
  44. package/lib/thin/sqlnet/constants.js +2 -0
  45. package/lib/thin/sqlnet/navNodes.js +30 -23
  46. package/lib/thin/sqlnet/networkSession.js +18 -14
  47. package/lib/thin/sqlnet/ntTcp.js +12 -6
  48. package/lib/thin/sqlnet/nvStrToNvPair.js +23 -26
  49. package/lib/thin/sqlnet/paramParser.js +42 -43
  50. package/lib/thin/sqlnet/sessionAtts.js +1 -1
  51. package/lib/thin/util.js +4 -3
  52. package/lib/traceHandler.js +133 -0
  53. package/lib/util.js +177 -33
  54. package/lib/version.js +2 -2
  55. package/package.json +1 -1
  56. package/build/Release/oracledb-6.6.0-darwin-arm64.node +0 -0
  57. package/build/Release/oracledb-6.6.0-darwin-arm64.node-buildinfo.txt +0 -1
  58. package/build/Release/oracledb-6.6.0-darwin-x64.node +0 -0
  59. package/build/Release/oracledb-6.6.0-darwin-x64.node-buildinfo.txt +0 -1
  60. package/build/Release/oracledb-6.6.0-js-buildinfo.txt +0 -1
  61. package/build/Release/oracledb-6.6.0-linux-arm64.node +0 -0
  62. package/build/Release/oracledb-6.6.0-linux-arm64.node-buildinfo.txt +0 -1
  63. package/build/Release/oracledb-6.6.0-linux-x64.node +0 -0
  64. package/build/Release/oracledb-6.6.0-linux-x64.node-buildinfo.txt +0 -1
  65. package/build/Release/oracledb-6.6.0-win32-x64.node +0 -0
  66. package/build/Release/oracledb-6.6.0-win32-x64.node-buildinfo.txt +0 -1
  67. package/examples/README.md +0 -138
@@ -0,0 +1,133 @@
1
+ // Copyright (c) 2024, Oracle and/or its affiliates.
2
+
3
+ //-----------------------------------------------------------------------------
4
+ //
5
+ // This software is dual-licensed to you under the Universal Permissive License
6
+ // (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7
+ // 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8
+ // either license.
9
+ //
10
+ // If you elect to accept the software under the Apache License, Version 2.0,
11
+ // the following applies:
12
+ //
13
+ // Licensed under the Apache License, Version 2.0 (the "License");
14
+ // you may not use this file except in compliance with the License.
15
+ // You may obtain a copy of the License at
16
+ //
17
+ // https://www.apache.org/licenses/LICENSE-2.0
18
+ //
19
+ // Unless required by applicable law or agreed to in writing, software
20
+ // distributed under the License is distributed on an "AS IS" BASIS,
21
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ // See the License for the specific language governing permissions and
23
+ // limitations under the License.
24
+ //
25
+ //-----------------------------------------------------------------------------
26
+
27
+ 'use strict';
28
+
29
+ /**
30
+ * TraceHandler interface defination which application needs to implement
31
+ * the hooks defined. The hooks will be called by the driver with traceContext
32
+ * data.
33
+ *
34
+ * TraceContext Data details.
35
+ * connectLevelConfig - Connection Config details.
36
+ * protcol - tcp/tcps protocol.
37
+ * user - user/schema associated.
38
+ * instanceName - instance Name.
39
+ * pdbName - PDB name.
40
+ * serviceName - service name.
41
+ * connectString - connect string passed.
42
+ * hostName - host name.
43
+ * port - port number.
44
+ * poolMin - pool Min.
45
+ * poolMax - pool Max.
46
+ * poolIncrement - pool Increment.
47
+ *
48
+ * callLevelConfig - Post connection, call leveldetails.
49
+ * statement - SQL statement.
50
+ * values - Bind values.
51
+ *
52
+ * additionalConfig - Custom Config based on the methods executed.
53
+ * args - input arguments of function.
54
+ * self - the current instance on which function is called.
55
+ * result - the result object returned after calling function.
56
+ * implicitRelease - true if implicit release is done.
57
+ *
58
+ */
59
+
60
+ class TraceHandlerBase {
61
+
62
+ constructor() {
63
+ this._config = {};
64
+ }
65
+
66
+ // check if sending traces is enabled.
67
+ isEnabled() {
68
+ return (this._config.enable);
69
+ }
70
+
71
+ // Enable sending traces
72
+ enable() {
73
+ this._config.enable = true;
74
+ }
75
+
76
+ // Disable sending traces
77
+ disable() {
78
+ this._config.enable = false;
79
+ }
80
+
81
+ // It is called before invoking a public async method.
82
+ onEnterFn(/*traceContext*/) {
83
+ }
84
+
85
+ // It is called after invoking a public async method.
86
+ // The same traceContext object passed inside onEnterFn
87
+ // will be passed in this function.
88
+ onExitFn(/*traceContext*/) {
89
+ }
90
+
91
+ // called when a round trip is begun
92
+ // OpenTelemetry will start a new span as a child of the public API span.
93
+ onBeginRoundTrip(/*traceContext*/) {
94
+ }
95
+
96
+ // called when a round trip has ended
97
+ // OpenTelemetry will end the span
98
+ // The same traceContext object passed inside onBeginRoundTrip
99
+ // is passed here.
100
+ onEndRoundTrip(/*traceContext*/) {
101
+ }
102
+
103
+ }
104
+
105
+ // singleton object pointing to traceHandler instance.
106
+ let _currentTraceObject;
107
+
108
+ // It enables user defined implementation of
109
+ // TraceHandlerBase interface to be used.
110
+ function setTraceInstance(obj) {
111
+ _currentTraceObject = obj;
112
+ }
113
+
114
+ // It returns the user defined instance implementing the interface.
115
+ function getTraceInstance() {
116
+ return _currentTraceObject;
117
+ }
118
+
119
+ // returns if tracing is enabled.
120
+ function isEnabled() {
121
+ return _currentTraceObject?.isEnabled();
122
+ }
123
+
124
+ module.exports = {
125
+ // class
126
+ TraceHandlerBase,
127
+
128
+ // methods
129
+ setTraceInstance,
130
+ getTraceInstance,
131
+ isEnabled
132
+
133
+ };
package/lib/util.js CHANGED
@@ -32,6 +32,16 @@ const process = require('process');
32
32
  const util = require('util');
33
33
  const types = require('./types.js');
34
34
  const constants = require('./constants.js');
35
+ const traceHandler = require('./traceHandler.js');
36
+
37
+ // set of valid network characters
38
+ const validNetworkCharacterSet = new Set(['A', 'B', 'C', 'D', 'E', 'F', 'G',
39
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
40
+ 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
41
+ 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
42
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '<', '>', '/', '\\', ',',
43
+ '.', ':', ';', '\'', '"', '-', '_', '$', '+', '*', '#', '&', '!', '%', '?',
44
+ '@']);
35
45
 
36
46
  // node-oracledb version number
37
47
  let packageJSON;
@@ -54,6 +64,17 @@ const BUILD_FILE = 'oracledb.node';
54
64
  // Staging directory used by maintainers building the npm package
55
65
  const STAGING_DIR = 'package/Staging';
56
66
 
67
+ //-----------------------------------------------------------------------------
68
+ // assertParamPropNetworkName()
69
+ //
70
+ // Asserts input vaue and sanitized value passes specified condition
71
+ // -----------------------------------------------------------------------------
72
+ function assertParamPropNetworkName(obj, parameterNum, propName) {
73
+ errors.assertParamPropString(obj, parameterNum, propName);
74
+ const sanitizedValue = sanitize(obj[propName]);
75
+ errors.assertParamPropValue(obj[propName] === sanitizedValue, parameterNum, propName);
76
+ }
77
+
57
78
  // getInstallURL returns a string with installation URL
58
79
  function getInstallURL() {
59
80
  return ('Node-oracledb installation instructions: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html');
@@ -113,6 +134,77 @@ function getInstallHelp() {
113
134
  return mesg;
114
135
  }
115
136
 
137
+ function getOperationName(methodName) {
138
+ const className = (this.constructor.name === 'Object') ? 'oracledb'
139
+ : `oracledb.${this.constructor.name}`;
140
+ return `${className}.${methodName}`;
141
+ }
142
+
143
+ // It returns an userContext after populating the traceContext with this below data.
144
+ // Operation derived from className, methodName.
145
+ // Initialize the callLevelTraceData.
146
+ // traceContext is filled.
147
+ function traceEnterFn(traceContext) {
148
+ if (!traceHandler.isEnabled()) {
149
+ return;
150
+ }
151
+
152
+ // initialize callLevel data
153
+ if (this._impl) {
154
+ this._impl._callLevelTraceData = {};
155
+ }
156
+
157
+ // fill the traceContext.
158
+ traceContext.additionalConfig = {};
159
+ traceContext.additionalConfig.self = this;
160
+ traceContext.additionalConfig.args = traceContext.args;
161
+ traceContext.operation = getOperationName.call(this, traceContext.fn.name);
162
+ traceContext.connectLevelConfig = this._impl?._getConnectTraceConfig();
163
+ traceHandler.getTraceInstance().onEnterFn(traceContext);
164
+ }
165
+
166
+ // It calls the onExitFn method providing the userContext resturned in onEnterFn.
167
+ function traceExitFn(traceContext, result, err) {
168
+ const callExitFn = traceHandler.isEnabled();
169
+ if (!callExitFn) {
170
+ return;
171
+ }
172
+
173
+ // Fill the traceContext.
174
+ traceContext.error = err;
175
+ traceContext.additionalConfig.result = result;
176
+ if (this._impl) {
177
+ // fill function call state.
178
+ traceContext.callLevelConfig = this._impl._callLevelTraceData;
179
+ }
180
+ if (['oracledb.getConnection', 'oracledb.createPool'].includes(traceContext.operation)) {
181
+ if (err) {
182
+ if (traceContext.args && traceContext.args.length >= 1) {
183
+ // connectString and user information is populated in traceContext,
184
+ // which is useful if an error happens and connection object is not created.
185
+ const config = {};
186
+ const inp = traceContext.args[0];
187
+ config.user = inp.user || inp.username;
188
+ config.connectString = inp.connectString || inp.connectionString;
189
+ traceContext.connectLevelConfig = config;
190
+ }
191
+ } else {
192
+ traceContext.connectLevelConfig = result._impl._getConnectTraceConfig();
193
+ }
194
+ } else if (traceContext.operation === 'oracledb.Pool.getConnection') {
195
+ if (!err) {
196
+ // we update the connectTraceConfig with more values with returned conn.
197
+ traceContext.connectLevelConfig = result._impl._getConnectTraceConfig();
198
+ }
199
+ }
200
+
201
+ traceHandler.getTraceInstance().onExitFn(traceContext);
202
+ if (this._impl) {
203
+ // cleanup the function call state.
204
+ this._impl._callLevelTraceData = undefined;
205
+ }
206
+ }
207
+
116
208
  // The callbackify function is used to wrap async methods to add optional
117
209
  // callback support. If the last parameter passed to a method is a function,
118
210
  // then it is assumed that the callback pattern is being used and the promise
@@ -124,9 +216,7 @@ function callbackify(func) {
124
216
  // if last argument is not a function, simply invoke the function as usual
125
217
  // and a promise will be returned
126
218
  if (typeof arguments[arguments.length - 1] !== 'function') {
127
- return func.apply(this, arguments).catch(function stackCapture(err) {
128
- throw errors.transformErr(err, stackCapture);
129
- });
219
+ return func.apply(this, arguments);
130
220
  }
131
221
 
132
222
  // otherwise, resolve or reject the promise and invoke the callback
@@ -134,9 +224,7 @@ function callbackify(func) {
134
224
  const cb = arguments[arguments.length - 1];
135
225
  func.apply(this, args).then(function(result) {
136
226
  cb(null, result);
137
- }, function stackCapture(err) {
138
- cb(errors.transformErr(err, stackCapture));
139
- });
227
+ }, cb);
140
228
  };
141
229
  if (func.name) {
142
230
  Object.defineProperty(wrapper, 'name', { value: func.name });
@@ -144,17 +232,30 @@ function callbackify(func) {
144
232
  return wrapper;
145
233
  }
146
234
 
147
- // The serialize function is used to wrap methods to ensure that the connection
148
- // is not used concurrently by multiple threads
149
- function serialize(func) {
150
- return async function() {
235
+ // the wrapFn() function is used to wrap a single method to ensure that calls
236
+ // are serialized and that concurrent calls are prevented where that is needed;
237
+ // this method also ensures that error information is captured correctly.
238
+ // If tracing is enabled, the hooks onEnterFn and onExitFn are called after
239
+ // the input traceContext is prepared. The func is passed in traceContext
240
+ // which is filled with additional context inside onEnterFn.
241
+ function wrapFn(func, serialize, preventConcurrentErrorCode) {
242
+ const wrapper = async function wrapper() {
151
243
 
152
244
  let connImpl;
245
+ const traceEnabled = traceHandler.isEnabled();
246
+ const traceContext = {fn: func, args: arguments};
247
+
248
+ // if concurrent operations are to be prevented, check for that now
249
+ if (preventConcurrentErrorCode) {
250
+ if (this._isActive)
251
+ errors.throwErr(preventConcurrentErrorCode);
252
+ this._isActive = true;
253
+ }
153
254
 
154
255
  // determine the connection implementation associated with the object, if
155
256
  // one currently exists and acquire the "lock"; this simply checks to see
156
257
  // if another operation is in progress, and if so, waits for it to complete
157
- if (this._impl) {
258
+ if (serialize && this._impl) {
158
259
  connImpl = this._impl._getConnImpl();
159
260
  await connImpl._acquireLock();
160
261
  }
@@ -162,48 +263,54 @@ function serialize(func) {
162
263
  // call the function and ensure that the lock is "released" once the
163
264
  // function has completed -- either successfully or in failure -- but only
164
265
  // if a connection implementation is currently associated with this object
266
+ let result, tErr;
165
267
  try {
166
- return await func.apply(this, arguments);
268
+ if (traceEnabled) {
269
+ traceEnterFn.call(this, traceContext);
270
+ }
271
+ result = await traceContext.fn.apply(this, arguments);
272
+ return result;
273
+ } catch (err) {
274
+ tErr = errors.transformErr(err, wrapper);
275
+ throw tErr;
167
276
  } finally {
168
277
  if (connImpl)
169
278
  connImpl._releaseLock();
279
+ if (preventConcurrentErrorCode) {
280
+ this._isActive = false;
281
+ }
282
+ if (traceEnabled) {
283
+ traceExitFn.call(this, traceContext, result, tErr);
284
+ }
170
285
  }
171
- };
172
- }
173
286
 
174
- function preventConcurrent(func, errorCode) {
175
- return async function() {
176
- if (this._isActive)
177
- errors.throwErr(errorCode);
178
- this._isActive = true;
179
- try {
180
- return await func.apply(this, arguments);
181
- } finally {
182
- this._isActive = false;
183
- }
184
287
  };
288
+ if (func.name) {
289
+ Object.defineProperty(wrapper, 'name', { value: func.name });
290
+ }
291
+ return wrapper;
185
292
  }
186
293
 
187
294
  // The wrapFns() function is used to wrap the named methods on the prototype
188
- // in multiple ways (serialize, preventConcurrent and callbackify); the
295
+ // so that a number of common tasks can be done in a single place; the
189
296
  // arguments following the formal arguments contain the names of methods to
190
297
  // wrap on the prototype; if the first extra argument is an error code, it is
191
298
  // used to wrap to prevent concurrent access
192
299
  function wrapFns(proto) {
193
300
  let nameIndex = 1;
301
+ let serialize = true;
194
302
  let preventConcurrentErrorCode;
195
303
  if (typeof arguments[1] === 'number') {
196
- nameIndex = 2;
304
+ nameIndex++;
197
305
  preventConcurrentErrorCode = arguments[1];
306
+ } else if (typeof arguments[1] === 'boolean') {
307
+ nameIndex++;
308
+ serialize = arguments[1];
198
309
  }
199
310
  for (let i = nameIndex; i < arguments.length; i++) {
200
311
  const name = arguments[i];
201
312
  const f = proto[name];
202
- if (preventConcurrentErrorCode) {
203
- proto[name] = callbackify(preventConcurrent(serialize(f),
204
- preventConcurrentErrorCode));
205
- } else
206
- proto[name] = callbackify(serialize(f));
313
+ proto[name] = callbackify(wrapFn(f, serialize, preventConcurrentErrorCode));
207
314
  }
208
315
  }
209
316
 
@@ -412,6 +519,42 @@ function makeDate(useLocal, year, month, day, hour, minute,
412
519
  fseconds) - offset * 60000);
413
520
  }
414
521
 
522
+ //---------------------------------------------------------------------------
523
+ // sanitize()
524
+ //
525
+ // this function replaces invalid characters in a string with characters
526
+ // guaranteed to be in the Network Character Set.
527
+ //---------------------------------------------------------------------------
528
+ function sanitize(text) {
529
+ let value = text.split('');
530
+
531
+ // if first character is single/double quote
532
+ if ((value[0] === '\'' || value[0] === '"')) {
533
+ value = value.splice(1);
534
+ }
535
+
536
+ // if last character is single/double quote
537
+ if ((value[value.length - 1] === '\'' || value[value.length - 1] === '"')) {
538
+ value.pop();
539
+ }
540
+
541
+ // look for invalid characters, and replace them with '?'
542
+ // in case of default values and throw an error
543
+ // for user provided values
544
+ for (let i = 0; i < value.length; i++) {
545
+ if (!validNetworkCharacterSet.has(value[i])) {
546
+ value[i] = '?';
547
+ }
548
+ }
549
+
550
+ // if last character is a backslash
551
+ if (value[value.length - 1] === '\\') {
552
+ value[value.length - 1] = '?';
553
+ }
554
+
555
+ return value.join('');
556
+ }
557
+
415
558
  // define exports
416
559
  module.exports = {
417
560
  BINARY_FILE,
@@ -420,6 +563,7 @@ module.exports = {
420
563
  RELEASE_DIR,
421
564
  STAGING_DIR,
422
565
  addTypeProperties,
566
+ assertParamPropNetworkName,
423
567
  callbackify,
424
568
  denormalizePrivateKey,
425
569
  getInstallURL,
@@ -436,8 +580,8 @@ module.exports = {
436
580
  isXid,
437
581
  normalizeXid,
438
582
  makeDate,
439
- preventConcurrent,
440
- serialize,
583
+ sanitize,
441
584
  verifySodaDoc,
585
+ wrapFn,
442
586
  wrapFns
443
587
  };
package/lib/version.js CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  module.exports = {
32
32
  VERSION_MAJOR: 6,
33
- VERSION_MINOR: 6,
34
- VERSION_PATCH: 0,
33
+ VERSION_MINOR: 7,
34
+ VERSION_PATCH: 1,
35
35
  VERSION_SUFFIX: ''
36
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oracledb",
3
- "version": "6.6.0",
3
+ "version": "6.7.1",
4
4
  "description": "A Node.js module for Oracle Database access from JavaScript and TypeScript",
5
5
  "license": "(Apache-2.0 OR UPL-1.0)",
6
6
  "homepage": "http://oracle.github.io/node-oracledb/",
@@ -1 +0,0 @@
1
- oracledb-6.6.0-darwin-arm64.node v22.2.0 6e81601d4d09137e859660fbbe090e1b272adbb2 5f182c720d6541c3b267d5d370f606f90b5b0c38 Wed, 17 Jul 2024 06:45:24 GMT
@@ -1 +0,0 @@
1
- oracledb-6.6.0-darwin-x64.node v20.11.1 6e81601d4d09137e859660fbbe090e1b272adbb2 5f182c720d6541c3b267d5d370f606f90b5b0c38 Wed, 17 Jul 2024 04:43:48 GMT
@@ -1 +0,0 @@
1
- 6e81601d4d09137e859660fbbe090e1b272adbb2
@@ -1 +0,0 @@
1
- oracledb-6.6.0-linux-arm64.node v20.12.2 6e81601d4d09137e859660fbbe090e1b272adbb2 5f182c720d6541c3b267d5d370f606f90b5b0c38 Wed, 17 Jul 2024 07:10:04 GMT
@@ -1 +0,0 @@
1
- oracledb-6.6.0-linux-x64.node v16.20.2 6e81601d4d09137e859660fbbe090e1b272adbb2 5f182c720d6541c3b267d5d370f606f90b5b0c38 Wed, 17 Jul 2024 07:13:04 GMT
@@ -1 +0,0 @@
1
- oracledb-6.6.0-win32-x64.node v18.16.0 6e81601d4d09137e859660fbbe090e1b272adbb2 5f182c720d6541c3b267d5d370f606f90b5b0c38 Wed, 17 Jul 2024 07:26:50 GMT
@@ -1,138 +0,0 @@
1
- # Node-oracledb Examples
2
-
3
- The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb) examples.
4
- Documentation is [here](https://node-oracledb.readthedocs.io/en/latest/).
5
-
6
- To run the examples:
7
-
8
- - [Install node-oracledb](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#quickstart).
9
-
10
- - Ensure that you navigate to the `examples` directory in your terminal window
11
- or IDE, where you are running the samples.
12
-
13
- - Review `dbconfig.js`.
14
-
15
- In your terminal window or IDE, set the following environment variables to
16
- provide credentials for the `dbconfig.js` file.
17
-
18
- - `NODE_ORACLEDB_USER` must be set to the database user.
19
-
20
- - `NODE_ORACLEDB_PASSWORD` must be set to the database password.
21
-
22
- - `NODE_ORACLEDB_CONNECTIONSTRING` must be set to the connection string that points to your database's location.
23
-
24
- - `NODE_ORACLEDB_EXTERNALAUTH` provides the options for enabling external authentication. Setting this environment variable to "true" will enable external authentication. To ensure external authentication works, firstly make sure the Oracle external authentication service is correctly configured. See [Documentation for External Authentication](https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth) for details.
25
-
26
- - `NODE_ORACLEDB_DRIVER_MODE` provides an option to set the 'Thin' or 'Thick' modes of node-oracledb. Setting this environment variable to "thick" will enable Thick mode.
27
- Setting it to "thin" will retain the Thin mode. The default mode is Thin.
28
-
29
- - `NODE_ORACLEDB_WALLET_LOCATION` must be set to the local directory name for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud
30
- Autonomous Databases optionally. The wallet location can also be provided as a part of the database connect string.
31
-
32
- - `NODE_ORACLEDB_WALLET_PASSWORD` must set to the password for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud Autonomous Databases.
33
-
34
- - `NODE_ORACLEDB_CLIENT_LIB_DIR` provides an optional path for the Oracle Client libraries to be used on Windows and macOS platforms, when using Thick mode in node-oracledb.
35
-
36
- Review the examples and then run them individually. For example, to see what
37
- the file `example.js` does, use:
38
-
39
- ```
40
- node example.js
41
- ```
42
-
43
- After running the examples, the demonstration objects can be dropped with
44
- `demodrop.js`:
45
-
46
- ```
47
- node demodrop.js
48
- ```
49
-
50
- Many examples can be run in either node-oracledb Thin (the default) or Thick
51
- modes. Thin mode is a pure JavaScript implementation of node-oracledb.
52
- Setting the environment variable `NODE_ORACLEDB_DRIVER_MODE` to `'thick'` will
53
- make examples use Thick mode.
54
-
55
- ## Example Overview
56
-
57
- If this is your first time with node-oracledb, start with
58
- [`example.js`](example.js).
59
-
60
- File Name | Description
61
- ----------------------------------------------------------|----------------------------------------------------------------------------------
62
- [`aqmulti.js`](aqmulti.js) | Oracle Advanced Queuing (AQ) example passing multiple messages
63
- [`aqobject.js`](aqobject.js) | Oracle Advanced Queuing (AQ) example passing an Oracle Database object
64
- [`aqoptions.js`](aqoptions.js) | Oracle Advanced Queuing (AQ) example setting options and message attributes
65
- [`aqraw.js`](aqraw.js) | Basic Oracle Advanced Queuing (AQ) example passing text messages
66
- [`aqutil.js`](aqutil.js) | Common file to setup the user credentials for all the Advanced Queuing (AQ) examples.
67
- [`blobhttp.js`](blobhttp.js) | Simple web app that streams an image
68
- [`calltimeout.js`](calltimeout.js) | Shows how to cancel a SQL statement if it doesn't complete in a specified time
69
- [`connect.js`](connect.js) | Basic example for creating a standalone (non-pooled) connection
70
- [`connectionpool.js`](connectionpool.js) | Basic example creating a pool of connections
71
- [`cqn1.js`](cqn1.js) | Basic Continuous Query Notification (CQN) example
72
- [`cqn2.js`](cqn2.js) | Continuous Query Notification with notification grouping
73
- [`date_timestamp1.js`](date_timestamp1.js) | Show some basic DATE and TIMESTAMP behaviors
74
- [`date_timestamp2.js`](date_timestamp2.js) | Show some DATE and TIMESTAMP behaviors with timezones
75
- [`dbconfig.js`](dbconfig.js) | Common file used by examples for setting connection credentials
76
- [`dbmsoutputgetline.js`](dbmsoutputgetline.js) | Show fetching DBMS_OUTPUT by binding buffers
77
- [`dbmsoutputpipe.js`](dbmsoutputpipe.js) | Show fetching DBMS_OUTPUT by using a pipelined table
78
- [`demodrop.js`](demodrop.js) | Drops the schema objects created by the examples
79
- [`demosetup.js`](demosetup.js) | Used to create common schema objects for the examples
80
- [`dmlrupd.js`](dmlrupd.js) | Example of DML RETURNING where multiple rows are matched
81
- [`em_batcherrors.js`](em_batcherrors.js) | `executeMany()` example showing handling data errors
82
- [`em_dmlreturn1.js`](em_dmlreturn1.js) | `executeMany()` example of DML RETURNING that returns single values
83
- [`em_dmlreturn2.js`](em_dmlreturn2.js) | `executeMany()` example of DML RETURNING that returns multiple values
84
- [`em_insert1.js`](em_insert1.js) | Array DML example using `executeMany()` with bind-by-name syntax
85
- [`em_insert2.js`](em_insert2.js) | Array DML example using `executeMany()` with bind by position
86
- [`em_plsql.js`](em_plsql.js) | `executeMany()` example calling PL/SQL multiple times with one call
87
- [`em_rowcounts.js`](em_rowcounts.js) | `executeMany()` example showing how to find the number of rows affected by each input row
88
- [`endtoend.js`](endtoend.js) | Example showing setting tracing attributes
89
- [`example.js`](example.js) | Basic example showing creating a table, inserting multiple rows, and querying rows
90
- [`impres.js`](impres.js) | Shows PL/SQL 'Implict Results' returning multiple query results from PL/SQL code.
91
- [`insert1.js`](insert1.js) | Basic example creating a table and inserting data. Shows DDL and DML
92
- [`insert2.js`](insert2.js) | Basic example showing auto commit behavior
93
- [`lastinsertid.js`](lastinsertid.js) | Shows inserting a row and getting its ROWID.
94
- [`lobbinds.js`](lobbinds.js) | Demonstrates how to bind and query LOBs
95
- [`lobinsert1.js`](lobinsert1.js) | Shows inserting a file into a CLOB column
96
- [`lobinsert2.js`](lobinsert2.js) | Inserts text into a CLOB column using the RETURNING INTO method.
97
- [`lobinserttemp.js`](lobinserttemp.js) | Writes data to a Temporary CLOB and then inserts it into the database
98
- [`lobplsqltemp.js`](lobplsqltemp.js) | Streams data into a Temporary CLOB and then passes it to PL/SQL
99
- [`lobselect.js`](lobselect.js) | Shows basic, non-streaming CLOB and BLOB queries
100
- [`lobstream1.js`](lobstream1.js) | Shows how to stream LOBs to files
101
- [`lobstream2.js`](lobstream2.js) | Shows using Stream data events to fetch a CLOB
102
- [`lowercasecolumns.js`](lowercasecolumns.js) | Shows how a type handler can convert column names to lower case
103
- [`metadata.js`](metadata.js) | Shows the metadata available after executing SELECT statements
104
- [`plsqlarray.js`](plsqlarray.js) | Examples of binding PL/SQL "INDEX BY" tables
105
- [`plsqlfunc.js`](plsqlfunc.js) | How to call a PL/SQL function
106
- [`plsqlproc.js`](plsqlproc.js) | How to call a PL/SQL procedure
107
- [`plsqlrecord.js`](plsqlrecord.js) | Shows binding of PL/SQL RECORDS
108
- [`plsqlvarrayrecord.js`](plsqlvarrayrecord.js) | Shows binding a VARRAY of RECORD in PL/SQL
109
- [`plsqlrowtype.js`](plsqlrowtype.js) | Shows binding of PL/SQL %ROWTYPE object
110
- [`raw.js`](raw.js) | Shows using a Buffer to insert and select a RAW
111
- [`refcursor.js`](refcursor.js) | Shows using a ResultSet to fetch rows from a REF CURSOR
112
- [`refcursortoquerystream.js`](refcursortoquerystream.js) | Converts a REF CURSOR returned from `execute()` to a query stream.
113
- [`resultset1.js`](resultset1.js) | Executes a query and uses a ResultSet to fetch rows with `getRow()`
114
- [`resultset2.js`](resultset2.js) | Executes a query and uses a ResultSet to fetch batches of rows with `getRows()`
115
- [`resultsettoquerystream.js`](resultsettoquerystream.js) | Converts a ResultSet returned from `execute()` into a Readable Stream.
116
- [`rowlimit.js`](rowlimit.js) | Shows ways to limit the number of records fetched by queries
117
- [`sampleazuretokenauth.js`](sampleazuretokenauth.js) | Shows connection pooling with Azure token based authentication.
118
- [`sampleocitokenauth.js`](sampleocitokenauth.js) | Shows connection pooling with OCI OAuth 2.0 token based authentication.
119
- [`select1.js`](select1.js) | Executes a basic query without using a connection pool or ResultSet
120
- [`select2.js`](select2.js) | Executes queries to show array and object output formats
121
- [`selectgeometry.js`](selectgeometry.js) | Insert and query Oracle Spatial geometries
122
- [`selectjson.js`](selectjson.js) | Shows some JSON features of Oracle Database 21c
123
- [`selectjsonblob.js`](selectjsonblob.js) | Shows how to use a BLOB as a JSON column store
124
- [`selectobject.js`](selectobject.js) | Insert and query a named Oracle database object
125
- [`selectnestedcursor.js`](selectnestedcursor.js) | Shows selecting from a nested cursor
126
- [`selectstream.js`](selectstream.js) | Executes a basic query using a Readable Stream
127
- [`selectvarray.js`](selectvarray.js) | Shows inserting and selecting from a VARRAY column
128
- [`sessionfixup.js`](sessionfixup.js) | Shows a pooled connection callback to efficiently set session state
129
- [`sessiontagging1.js`](sessiontagging1.js) | Simple pooled connection tagging for setting session state
130
- [`sessiontagging2.js`](sessiontagging2.js) | More complex example of pooled connection tagging for setting session state
131
- [`soda1.js`](soda1.js) | Basic Simple Oracle Document Access (SODA) example
132
- [`typehandlerdate.js`](typehandlerdate.js) | Show how a type handler can format a queried date in a locale-specific way
133
- [`typehandlernum.js`](typehandlernum.js) | Show how a type handler can alter queried numbers
134
- [`vectortype1.js`](vectortype1.js) | Insert and query VECTOR columns.
135
- [`vectortype2.js`](vectortype2.js) | Insert data into VECTOR columns and verify vector operations.
136
- [`version.js`](version.js) | Shows the node-oracledb version attributes
137
- [`webapp.js`](webapp.js) | A simple web application using a connection pool
138
- [`xmltypeInDbObject.js`](xmltypeInDbObject.js) | Work with XMLType data in DbObject (Thin mode only)