【问题标题】:Error closing node-oracledb pool connections with Oracle DB and Node.js关闭与 Oracle DB 和 Node.js 的 node-oracledb 池连接时出错
【发布时间】:2020-01-04 06:48:16
【问题描述】:

我在关闭与 Oracle 中的数据库的连接时遇到问题。 首先,我创建连接没有任何问题。

  try {
  console.log('Initializing database module');

  await database.initialize();
  } catch (err) {
  console.error(err);

  process.exit(1); // Non-zero failure code
  }


async function initialize() {
  console.log(dbConfig.hrPool);
  const pool = await oracledb.createPool(dbConfig.hrPool);
}

module.exports.initialize = initialize;

当我想关闭连接时,应用程序正在等待而没有任何响应,所以我这样做是为了结束连接

  try {
  console.log('Closing database module');
  console.log(" here 1");
  await database.close();// line  whit problem
  console.log(" here 2");
  } catch (err) {
  console.log('Encountered error', e);

  err = err || e;
  }

async function close() {
  await oracledb.getPool().close();
}

module.exports.close = close;


另请注意,我对数据库使用 vpn 连接

【问题讨论】:

    标签: node.js oracle oracle-sqldeveloper node-oracledb


    【解决方案1】:

    评论pool.close()documentation

    1. 您可能想要指定一个drainTime 值,否则池可能不会真正关闭。

    2. 您可能需要将DISABLE_OOB=ON 添加到 sqlnet.ora 文件中

    【讨论】:

    • 第二个选项对我有用,非常感谢!
    • 当你有 19c 客户端库和数据库时,这个设置不应该是明确需要的:它将由 Oracle 自动确定
    猜你喜欢
    • 2021-02-09
    • 2016-12-31
    • 2022-07-06
    • 2022-08-17
    • 2018-10-25
    • 2018-09-09
    • 2018-03-13
    • 2011-03-09
    • 1970-01-01
    相关资源
    最近更新 更多