Search code examples
javascriptnode.jsoraclenode-oracledb

Why am I getting the "NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode" error with node-oracledb


I tried using the latest node-oracledb 6.0.1 thin mode to connect my simple Node.js app to my Oracle Database 11g version and got an NJS-138 error.

I ran the following simple app using node-oracledb 6.0.1 in Thin mode:

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();

This gives the following error: NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode

Why is this error thrown?


Solution

  • node-oracledb 6.0 Thin mode supports Oracle Database Release 12.1 and later. Please see the following documentation: https://node-oracledb.readthedocs.io/en/latest/user_guide/appendix_a.html#id1 for the supported Oracle releases for both the Thin and Thick modes.

    Node-oracledb 6.0 is a 'Thin mode' driver by default. You can switch to Thick mode for Oracle Database 11g support or upgrade your database version.