Node.js 和 node-oracle : Problems connecting to Oracle database

标签 node.js oracle node-oracledb

我正在编写一个 Node.js 应用程序,用于从 Oracle 数据库中提取数据。 DBA 最近将数据库迁移到另一台机器上,一切都崩溃了。

我尝试重新创建 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;
            }

        });

最佳答案

我可以使用 sqlplus 连接,但不能使用 Nodejs。我是这样连接的

oracledb.getConnection(
  {
    user          : "test",
    password      : "test",
    connectString : "150.150.50.50:1521/MYDB"
  }

对我有用的解决方案是编辑 sqlnet.ora 文件并更改

names.directory_path = (TNSNAMES)

names.directory_path = (TNSNAMES, EZCONNECT)

关于Node.js 和 node-oracle : Problems connecting to Oracle database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11568428/

相关文章:

node.js - typescript 文件更改后 JavaScript 文件未更新

node.js - 是否可以向所有事件的 WebSocket 连接发送消息?使用 node.js 或 python tornado websockets

node.js - 如何限制对 Node.js 服务器的直接访问

sql - 热修复: not connected error when execution the sql statement, DPI-1010:not connected?

javascript - NPM Oracle : Inserting BLOBs

javascript - Express 呈现index.html 但不呈现其他页面

database - 如何同步两个 Oracle 数据库?

mysql - NOT IN 子句和 NULL 值

java - 更改现有数据的 Hibernate 序列生成