Exercise yourself with node-oracledb examples against an oracle database running in a Docker container


Install Docker

Pull container database instructions here.

Run database container as follows (orcldb is the container name I choosed):

docker run -d -it --name orcldb -P store/oracle/database-enterprise:12.2.0.1

[Please note that this database container instances a CDB named ORCLCDB which has a PDB named ORCLPDB1]

Install sample hr schema following this and set the password as welcome1, then issue this command for executing sqlplus in the container:

docker exec -it orcldb bash -c "source /home/oracle/.bashrc; sqlplus / as sysdba"
SQL> alter session set container = orclpdb1;
Session altered.

SQL> @?/demo/schema/human_resources/hr_main.sql

specify password for HR as parameter 1:

Enter value for 1: welcome1

specify default tablespeace for HR as parameter 2:

Enter value for 2: users

specify temporary tablespace for HR as parameter 3:

Enter value for 3: temp

specify log path as parameter 4:

Enter value for 4: .
...
Commit complete.
PL/SQL procedure successfully completed.
not spooling currently

Obtain the listener port as follows:

docker port orcldb

1521/tcp -> 0.0.0.0:32769

5500/tcp -> 0.0.0.0:32768

Follow steps here for node-oracledb setup except for the dbconfig.js file which must be set as follows:

module.exports = {

  user          : process.env.NODE_ORACLEDB_USER || "hr",

  password      : process.env.NODE_ORACLEDB_PASSWORD || "welcome1",

  connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost:32769/ORCLPDB1.localdomain",

  externalAuth  : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false

};

Execute one of the examples in $installdir/node-oracledb-master/examples

node select1.js

[ { name: ‘DEPARTMENT_ID’ }, { name: ‘DEPARTMENT_NAME’ } ]

[ [ 180, ‘Construction’ ] ]

Enjoy 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.