You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何使用node-oracledb 6.0.1 Thin模式连接Oracle 11g会报NJS-138错误?

问题:node-oracledb 6.0.1 Thin模式连接Oracle 11g触发NJS-138错误

运行以下Node.js代码尝试连接Oracle 11g时:

const oracledb = require('oracledb');

async function runApp() {
    let connection;
    let dbConfig = {
        user          : "scott",
        password      : "tiger",
        connectString : "localhost/orclpdb"
      };
      //oracledb.initOracleClient();
 
      // Get a standalone Oracle Database connection
      connection = await oracledb.getConnection(dbConfig);
      console.log('Connection was successful!');

      // Run a simple SQL on the connection
      const sql = `SELECT sysdate FROM dual`;
      const result = await connection.execute(sql);
      console.log(`The system date and time is:\n${result.rows[0][0]}`);
      await connection.close();
      
      if (oracledb.thin)
        console.log("Thin mode selected");
      else
    console.log("Thick mode selected");

    console.log("Run at: " + new Date());
    console.log("Node.js version: " + process.version + " (" + process.platform, process.arch + ")");
    console.log("Node-oracledb version:", oracledb.versionString);
}
runApp();

触发错误:

NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode

错误原因

NJS-138错误的核心原因是node-oracledb 6.x版本的Thin模式不兼容Oracle Database 11g:

  • node-oracledb 6.0新增的Thin模式仅支持Oracle Database 12c Release 2(12.2)及以上版本
  • Oracle 11g属于老旧版本,不在Thin模式的支持列表中
  • 若要连接Oracle 11g,必须切换到Thick模式:取消代码中oracledb.initOracleClient();的注释,并确保本地安装了对应版本的Oracle Client驱动

内容的提问来源于stack exchange,提问作者Sharad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 22:05:20