?
Prerequisite
Install the Oralce client driver.
Install node. js.
?
Create a project
Installing the OracleDB module
$NPM Install OracleDB
If you fail, you may have to climb the wall.
?
Reference Package.json
{
"Name": "Oracle-demo",
"Version": "1.0.0",
"description": "" ,
"Main": "App.js",
"Scripts": {
"Test": "echo \" Error:no test specified\ "&& exit 1"
},
"Author": "" ,
"License": "ISC",
?
"Dependencies": {
"OracleDB": "2.1.2 "
}
}
?
Reference source
var oracledb = require (' oracledb ');
?
Oracledb.getconnection ({
User: "Bob",
Password: "Bob",
ConnectString: "127.0.0.1/bob"
},
function(err, connection) {
If (err) {
Console.error (Err.message);
return;
}
?
Console.log (' Connection was successful! ' );
Connection.Execute (
' SELECT * from person ',
function(err, result) {
If (err) {
Console.error (Err.message);
Dorelease (connection);
return;
}
Console.log (result.rows);
Dorelease (connection);
});
}
);
?
function Dorelease (connection) {
Connection.close (
function(err) {
If (err)
Console.error (Err.message);
});
}
?
?
Reference Resources
Https://github.com/oracle/node-oracledb
Https://npm.taobao.org/package/oracledb
?
Oracle builds the node. JS Development environment