我正在编写一个从Oracle数据库中提取数据的Node.js应用程序。 DBA最近将数据库迁移到另一台机器上,一切都破裂了。Node.js和node-oracle:连接到Oracle数据库的问题
我试过重新创建tnsnames.ora和sqlnet.ora文件。我确信它们是正确的,因为sqlplus可以很好地连接到服务。但node-oracle持续报告错误:“ORA-12154:TNS:无法解析指定的连接标识符”。
这对我来说是莫名其妙的。在我看来,如果我设置了我的ORACLE_HOME环境变量,那么node-oracle和sqlplus应该功能相同。我究竟做错了什么?
我试过切换到node-db-oracle,但它报告了同样的问题。我很难过。
编辑:这是我如何连接:
database = new oracle.Database({
hostname: Preferences["oracle_host"], // FQDN of the database
port: Preferences["oracle_port"],
user: Credentials["oracle_login"],
password: Credentials["oracle_password"],
database: Preferences["oracle_database"]
});
connection = database.connect(function(error) {
if(error) {
Utilities.logger.error(error);
}
else {
Utilities.logger.info("Connected to Oracle database " + Preferences["oracle_host"]);
if(callback) callback.call(this, collection, options);
connection = this;
}
});
的例子为在github上显示两个驱动程序'connect'中定义的主机名等;那么你确定他们甚至提到'tnsnames.ora'? (我从来没有用过,清楚!)你可以发布你如何连接? – 2012-07-19 22:04:17
编辑以显示我如何连接 – Aqueous 2012-07-24 14:49:06
好吧,那么您是否已在更新'Preferences'值的地方更新了'oracle_host',以便它指向新的服务器?这不会经过'tnsnames.ora'。 – 2012-07-24 14:55:07