nodejs连接oracle
var oracledb = require('oracledb');
var config = {
"user": "scott",
"password": "123456",
"connectString":"localhost:1521/ORCL"
}
oracledb.getConnection(config,function (err,connection) {
if(err) {
console.log(err.message);
doRelease(connection);
return;
}
connection.execute("select * from dic_roles",function (err,result) {
if(err) {
console.error(err.message);
doRelease(connection);
return;
}
// 打印返回的表结构
console.log("========" + result.metaData);
// console.log(JSON.parse(result));
console.log(result.rows);
});
});
function doRelease(connection) {
connection.close(function (err) {
if(err) {
console.error(err.message)
}
})
}
执行报错后,执行下面代码
npm i oracledb –registry=https://registry.npm.taobao.org
转载自:https://blog.csdn.net/pengfeifei26/article/details/84926234