Skip to content

Commit 4002bb5

Browse files
authored
Merge latest Node.js examples for node-oracledb 6.3 (oracle-samples#309)
* Update files for the node-oracledb 6.3 version * Delete javascript/node-oracledb/date.js * Delete extra file * Delete extra file
1 parent f5e2416 commit 4002bb5

Some content is hidden

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

75 files changed

+11089
-8817
lines changed

javascript/node-oracledb/README.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
11
# Node-oracledb Examples
22

3-
This directory contains [node-oracledb](https://www.npmjs.com/package/oracledb)
4-
examples. Documentation is
5-
[here](https://oracle.github.io/node-oracledb/doc/api.html).
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/).
65

76
To run the examples:
87

9-
- [Install node-oracledb](https://oracle.github.io/node-oracledb/INSTALL.html#quickstart).
8+
- [Install node-oracledb](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#quickstart).
109

11-
- Edit `dbconfig.js` and set your username and the database connection string,
12-
for example:
10+
- Ensure that you navigate to the `examples` directory in your terminal window
11+
or IDE, where you are running the samples.
1312

14-
```
15-
module.exports = {
16-
user: "hr",
17-
password: process.env.NODE_ORACLEDB_PASSWORD,
18-
connectString:"localhost/orclpdb1"
19-
};
13+
- Review `dbconfig.js`.
2014

21-
```
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.
2223

23-
- In a terminal window, set the environment variable `NODE_ORACLEDB_PASSWORD` to
24-
the value of your database password.
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.
2525

26-
- Review the samples and then run them individually. For example, to see what
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
2737
the file `example.js` does, use:
2838

2939
```
3040
node example.js
3141
```
3242

33-
- After running examples, the demonstration objects can be dropped with
43+
After running the examples, the demonstration objects can be dropped with
3444
`demodrop.js`:
3545

3646
```
3747
node demodrop.js
3848
```
3949

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+
4055
## Example Overview
4156

4257
If this is your first time with node-oracledb, start with
@@ -48,13 +63,15 @@ File Name | Description
4863
[`aqobject.js`](aqobject.js) | Oracle Advanced Queuing (AQ) example passing an Oracle Database object
4964
[`aqoptions.js`](aqoptions.js) | Oracle Advanced Queuing (AQ) example setting options and message attributes
5065
[`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.
5167
[`blobhttp.js`](blobhttp.js) | Simple web app that streams an image
5268
[`calltimeout.js`](calltimeout.js) | Shows how to cancel a SQL statement if it doesn't complete in a specified time
5369
[`connect.js`](connect.js) | Basic example for creating a standalone (non-pooled) connection
5470
[`connectionpool.js`](connectionpool.js) | Basic example creating a pool of connections
5571
[`cqn1.js`](cqn1.js) | Basic Continuous Query Notification (CQN) example
5672
[`cqn2.js`](cqn2.js) | Continuous Query Notification with notification grouping
57-
[`date.js`](date.js) | Show some DATE and TIMESTAMP behaviors
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
5875
[`dbconfig.js`](dbconfig.js) | Common file used by examples for setting connection credentials
5976
[`dbmsoutputgetline.js`](dbmsoutputgetline.js) | Show fetching DBMS_OUTPUT by binding buffers
6077
[`dbmsoutputpipe.js`](dbmsoutputpipe.js) | Show fetching DBMS_OUTPUT by using a pipelined table
@@ -70,7 +87,6 @@ File Name | Description
7087
[`em_rowcounts.js`](em_rowcounts.js) | `executeMany()` example showing how to find the number of rows affected by each input row
7188
[`endtoend.js`](endtoend.js) | Example showing setting tracing attributes
7289
[`example.js`](example.js) | Basic example showing creating a table, inserting multiple rows, and querying rows
73-
[`fetchinfo.js`](fetchinfo.js) | Show how numbers and dates can be returned as strings using `fetchAsString` and `fetchInfo`
7490
[`impres.js`](impres.js) | Shows PL/SQL 'Implict Results' returning multiple query results from PL/SQL code.
7591
[`insert1.js`](insert1.js) | Basic example creating a table and inserting data. Shows DDL and DML
7692
[`insert2.js`](insert2.js) | Basic example showing auto commit behavior
@@ -83,6 +99,7 @@ File Name | Description
8399
[`lobselect.js`](lobselect.js) | Shows basic, non-streaming CLOB and BLOB queries
84100
[`lobstream1.js`](lobstream1.js) | Shows how to stream LOBs to files
85101
[`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
86103
[`metadata.js`](metadata.js) | Shows the metadata available after executing SELECT statements
87104
[`plsqlarray.js`](plsqlarray.js) | Examples of binding PL/SQL "INDEX BY" tables
88105
[`plsqlfunc.js`](plsqlfunc.js) | How to call a PL/SQL function
@@ -96,6 +113,8 @@ File Name | Description
96113
[`resultset2.js`](resultset2.js) | Executes a query and uses a ResultSet to fetch batches of rows with `getRows()`
97114
[`resultsettoquerystream.js`](resultsettoquerystream.js) | Converts a ResultSet returned from `execute()` into a Readable Stream.
98115
[`rowlimit.js`](rowlimit.js) | Shows ways to limit the number of records fetched by queries
116+
[`sampleazuretokenauth.js`](sampleazuretokenauth.js) | Shows connection pooling with Azure token based authentication.
117+
[`sampleocitokenauth.js`](sampleocitokenauth.js) | Shows connection pooling with OCI OAuth 2.0 token based authentication.
99118
[`select1.js`](select1.js) | Executes a basic query without using a connection pool or ResultSet
100119
[`select2.js`](select2.js) | Executes queries to show array and object output formats
101120
[`selectgeometry.js`](selectgeometry.js) | Insert and query Oracle Spatial geometries
@@ -109,5 +128,7 @@ File Name | Description
109128
[`sessiontagging1.js`](sessiontagging1.js) | Simple pooled connection tagging for setting session state
110129
[`sessiontagging2.js`](sessiontagging2.js) | More complex example of pooled connection tagging for setting session state
111130
[`soda1.js`](soda1.js) | Basic Simple Oracle Document Access (SODA) example
131+
[`typehandlerdate.js`](typehandlerdate.js) | Show how a type handler can format a queried date in a locale-specific way
132+
[`typehandlernum.js`](typehandlernum.js) | Show how a type handler can alter queried numbers
112133
[`version.js`](version.js) | Shows the node-oracledb version attributes
113134
[`webapp.js`](webapp.js) | A simple web application using a connection pool

0 commit comments

Comments
 (0)