How to connect Node.js 14 LTS to Oracle Database 23c FREE using node-oracledb

Опубликовано: 28 Сентябрь 2024
на канале: java frm
27
0

In this video we are going to see How to connect Node.js 14 to Oracle Database 23c FREE instance using node-oracledb add-on.
1. First check nodejs is available in commandline (node --version, npm --version).
2. Go to Source code directory in commandline and run "npm install oracledb".
3. Finally run the js program "node oracle23c.js"

Node.js and node-oracledb add-on can be downloaded from:

https://nodejs.org/download/release/v...
https://github.com/oracle/node-oracledb


Below is the program to connect NodeJS to Oracle Database 23c FREE instance.

IMPORTANT NOTE on SOURCE CODE: only source code that are acceptable by the youtube description box will be displayed.
In this program I have replaced the angled brackets with > or <. once you copy the source code to editor replace it with greater than or less than symbols respectively.
#########################SOURCE CODE STARTS HERE##############################
const oracledb = require('oracledb');

async function run() {
let connection = await oracledb.getConnection({
user : "C##Scott",
password : "tiger",
connectString : "localhost:1521/FREE" // [hostname]:[port]/[DB service name]
});
let query = 'SELECT * from person';

connection.execute(query, (err, rows) => {
if(err) throw err;

console.log(rows);
});
}
run();
#########################END OF SOURCE CODE##############################

#nodejs #nodejs14 #nodejstutorial #nodejsoracle #oraclenodejs #nodejsdatabase #nodeoracledb #23c #oracle