0

我正在研究 nodejs oracledb。我想从 nodejs oracledb 客户端以SYSDBA身份登录到 oracle db。请建议

下面是正在尝试的片段

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

但我收到一个错误:

ORA-28009: 作为 SYS 的连接应该是 SYSDBA 或 SYSOPER

4

3 回答 3

1

node-oracledb 2.1.0 的变化包括:

支持独立连接中的 SYSDBA、SYSOPER、SYSASM、SYSBACKUP、SYSDG、SYSKM 和 SYSRAC 权限。您现在可以像这样连接:

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');
      }
      // . . .
    );

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

于 2019-07-03T06:04:50.653 回答
1

node-oracledb(从 V1.5 开始)没有必要的底层 OCI 代码来支持特权身份验证。它在待办事项清单上。你要它干什么?

于 2016-01-22T22:49:31.433 回答
0

从NodeJS Web 应用程序连接到“Oracle 19c”版本时,只能使用设置“privilege: oracledb.SYSDBA”。如果没有设置 NodeJS Web 应用程序会抛出错误“状态:失败 - 测试失败:ORA-01017:用户名/密码无效;登录被拒绝”。

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

于 2020-03-30T13:08:59.290 回答