尝试使用节点访问远程数据库。这是我的代码
var oracle = require('oracle');
var cntdata = {
hostname: "xyz.sv3.corp.xxx.com",
port: 1521,
database: "qa.sv3.corp.xxx.com",
user: "xxx",
password: "xxxx"
}
oracle.connect(cntdata, function(error,connection){
if(error){console.log(error);
return console.log("connectivity failed");
}
connection.execute("SELECT systimestamp FROM dual", [], function(err, results) {
if (err) { console.log("Error executing query:", err); return; }
console.log(results);
connection.close(); // call only when query is finished executing
});
});
我还在/ etc / hosts文件中输入了172.20.200.00 xyz.sv3.corp.xxx.com
当我执行app.js时失败并显示错误:ORA-21561:OID生成失败....请帮忙!
答案 0 :(得分:1)
可以通过简单编辑主机文件来修复此问题:
只需输入' hostname'即可找到您的localhost系统的名称。在终端/命令提示符中。让我们假设您的机器被称为“机器”'然后将/ etc / hosts文件编辑为:127.0.0.1 localhost the_machine
$ hostname:
the_machine
$ vi / etc / hosts:
127.0.0.1 localhost the_machine
$ python Connect_to_Oracle_DB.py
干杯!