oracle数据库无法与knex连接

问题描述 投票:0回答:1

下午好。

我正在尝试使用 knex 连接 oracle 数据库。 但是,每当我尝试连接时,我都会收到一条 NJS-500 消息。 我用 knex 创建了一个 nodejs 服务。 我尝试过不同的方法,厚的/薄的,但我总是犯错误。 我已经检查过防火墙和安全端口。 如果我错过了什么,有人知道吗? 有没有其他替代工具可以代替 knex? 不过在sqldeveloper、sqlplus、tnsping、dbeaver中都可以正常连接。

这是我的代码:

const knex = require('knex')({
client: 'oracledb',
connection: {
host: '10.211.2.110',
port: 1521,
user: 'USER_SUP',
password: 'ABCDabcd123**',
database: 'superdr_pdb1.paas.oracle.com',
},
});
knex.raw('SELECT 1 FROM DUAL')
.then(() => {
console.log('Conexão estabelecida com sucesso!');
})
.catch((err) => {
console.error('Falha ao estabelecer conexão:', err);
})
.finally(() => {
knex.destroy(); // Fecha a conexão após o teste
});

版本:

"knex-oracledb-connection",
"version": "1.0.0",
"dependencies": {
"knex": "^3.1.0",
"oracledb": "^6.6.0"
node.js oracle knex.js node-oracledb
1个回答
0
投票

通常我的 knexfile.js 看起来像:

module.exports = {

  development: {
    client: 'oracledb',
    connection: {
      user          : "scott",
      password      : "tiger",
      connectString : "localhost:1521/orclpdb1"
    }
  },
  migrations: {
    directory: "./db/migrations"
  }

};
© www.soinside.com 2019 - 2024. All rights reserved.