我有连接,但我不知道它是否存在于连接键 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;
我正在一个选择简单的 collun
但始终返回错误:
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"
和膝盖呼叫:
var conn = knex({
client: 'oracledb',
connection: {
host: config.oracle.host,
user: config.oracle.user,
password: config.oracle.password,
database: config.oracle.database,
}
});
以防有人需要传递连接字符串。但请注意,连接字符串中的详细信息需要与你自己的环境匹配。
const oracledb = require("oracledb");
oracledb.initOracleClient({ libDir: "C:\oracle\instantclient_12_1" });
const knex = require("knex")({
client: "oracledb",
connection: {
user: "YOUR_USER",
password: "YOUR_PASSWORD",
connectString: "(DESCRIPTION=(CONNECT_TIMEOUT=10)(RETRY_COUNT=3)(SOURCE_ROUTE=yes)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=tcp)(HOST=your2.domain.com)(PORT=11529))(ADDRESS=(PROTOCOL=tcp)(HOST=your2.domain.com)(PORT=11529)))(ADDRESS_LIST=(FAILOVER=on)(LOAD_BALANCE=off)(ADDRESS=(PROTOCOL=tcp)(HOST=your3.domain.com)(port=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=your4.domain.com)(port=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=YOUR_SERVICE.your5.domain.com)))",
requestTimeout: 100
},
fetchAsString: ["number", "clob"]
});
knex.select().from("TABLE1").asCallback(function(err, rows){
if(err)
console.log(err);
else
console.table(rows);
});