node.js - 如何连接 KnexJS 和数据库 Oracle?

标签 node.js oracle knex.js

我有连接,但我不知道它是否存在于连接 key odbc... 但即使我将其丢弃,下面通知的错误仍然存​​在

const knex = require('knex');

// connection database
const dbmdlog = knex({
  client: 'oracle',
  connection: {
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'mydb',
    odbc: 'MYDB'
  }
});

module.exports = dbmdlogp;

我在一个列中做一个简单的选择
但总是返回错误:

  Unhandled rejection TypeError: _this2.driver.connect is not a function
        at /var/www/html/myapp/node_modules/knex/lib/dialects/oracle/index.js:143:21
        at Promise._execute (/var/www/html/myapp/node_modules/bluebird/js/release/debuggability.js:299:9)
        at Promise._resolveFromExecutor (/var/www/html/myapp/node_modules/bluebird/js/release/promise.js:481:18)
        at new Promise (/var/www/html/myapp/node_modules/bluebird/js/release/promise.js:77:14)
        at Client_Oracle.acquireRawConnection (/var/www/html/myapp/node_modules/knex/lib/dialects/oracle/index.js:142:12)
        at Object.create (/var/www/html/myapp/node_modules/knex/lib/client.js:231:16)
        at Pool._createResource (/var/www/html/myapp/node_modules/generic-pool/lib/generic-pool.js:326:17)
        at Pool.dispense [as _dispense] (/var/www/html/myapp/node_modules/generic-pool/lib/generic-pool.js:314:12)
        at Pool.acquire (/var/www/html/myapp/node_modules/generic-pool/lib/generic-pool.js:392:8)
        at /var/www/html/myapp/node_modules/knex/lib/client.js:281:19
        at Promise._execute (/var/www/html/myapp/node_modules/bluebird/js/release/debuggability.js:299:9)
        at Promise._resolveFromExecutor (/var/www/html/myapp/node_modules/bluebird/js/release/promise.js:481:18)
        at new Promise (/var/www/html/myapp/node_modules/bluebird/js/release/promise.js:77:14)
        at Client_Oracle.acquireConnection (/var/www/html/myapp/node_modules/knex/lib/client.js:272:12)

        at /var/www/html/myapp/node_modules/knex/lib/runner.js:200:30
     at Promise._execute (/var/www/html/myapp/node_modules/bluebird/js/release/debuggability.js:299:9)

最佳答案

knex 和 OracleDB 的组合工作正常。以下是来自 package.json 的包:"knex": "0.13.0", "oracledb": "1.13.1"

然后 knex 调用:

var conn = knex({
  client: 'oracledb',
  connection: {
    host: config.oracle.host,
    user: config.oracle.user,
    password: config.oracle.password,
    database: config.oracle.database,
  }
});

关于node.js - 如何连接 KnexJS 和数据库 Oracle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41705780/

相关文章:

node.js - 在node中使用ffmpeg,而不使用fluid-ffmpeg

oracle - Oracle Database Express 是否有免费的 GUI 管理工具?

linux - 使用 Oracle 12.1 客户端在 Linux 中迁移应用程序时在查询中添加小数秒

javascript - 在 Node API 混淆中使用 knex.js 编写插入语句

javascript - knex 的选择出现意外行为

javascript - 具有外键约束的 Knex chop 表

node.js - ECS Fargate 上的 EFS 挂载 - 拒绝非 root 用户的读/写权限

node.js - Socket.io 需要很长时间才能连接

带有sql语句的Java JDBC exec过程

node.js - 正则表达式忽略字符集前面的单词