0

I am working on nodejs oracledb.I would want to login to oracle db from nodejs oracledb client as SYSDBA.Please suggest

Below is the snippet which am trying

oracleSYS3.getConnection({
            user          :"sys",
            password      :"*******",
            connectString :"connectionString"},function(){}) 

But I'm getting an error:

ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48

3 Answers3

1

node-oracledb (as of V1.5) does not have the necessary underlying OCI code needed to support privileged authentication. It's on the todo list. What do you want it for?

Christopher Jones
  • 9,449
  • 3
  • 24
  • 48
1

Changes in node-oracledb 2.1.0 include:

Support for SYSDBA, SYSOPER, SYSASM, SYSBACKUP, SYSDG, SYSKM, and SYSRAC privileges in standalone connections. You can now connect like:

oracledb.getConnection(
    {
        user: 'sys',
        password: 'secret',
        connectString: 'localhost/orclpdb',
        privilege: oracledb.SYSDBA
      },
      function(err, connection) {
        if (err)
          console.error(err);
        else
          console.log('I have power');
      }
      // . . .
    );

See https://blogs.oracle.com/opal/node-oracledb-21-is-now-available-from-npm

crowne
  • 8,456
  • 3
  • 35
  • 50
0

When connecting to "Oracle 19c" version from NodeJS Web Application is working only with the setting "privilege: oracledb.SYSDBA". With out the setting NodeJS Web App is throwing an error "Status : Failure -Test failed: ORA-01017: invalid username/password; logon denied".

//KP : NodeJS Oracle19c DB Connection
// // This example uses Node 8's async/await syntax.
const oracledb = require('oracledb');
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
const mypw = "myorapassword";  // set mypw to the hr schema password

async function run() {

  let connection;

  try {
      connection = await oracledb.getConnection(  
        {
          user      : "SYS as SYSDBA",
          password  : myorapassword,
          privilege : oracledb.SYSDBA,
          connectionString: `(DESCRIPTION=
                                (ADDRESS=
                                    (PROTOCOL=TCP)
                                    (HOST=localhost)
                                    (PORT=1521)
                                  )
                                  (CONNECT_DATA=
                                    (SERVICE_NAME=orcl)
                                    (SERVER=DEDICATED)
                                  )
                                )`  
        }
      );
    console.log('KP : Oracle & NodeJS Connection  was Successful!');
    const result = await connection.execute(
      "Select name, open_mode, cdb from v$database"
    );
    console.log(result.rows);
  } catch (err) {
    console.error(err);
  } finally {
    if (connection) {
      try {
        await connection.close();
      } catch (err) {
        console.error(err);
      }
    }
  }
}
run();