为何使用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
相关产品推荐
相关产品推荐

