错误:ORA-12154,在使用knex node.js时可以执行oracle数据库查询

时间:2019-12-19 04:57:11

标签: node.js oracle knex.js

我正在使用knex在oracle数据库上工作。

这是我执行SQL查询的代码。

const knex = require('knex')({
  client: 'oracledb',
  connection: {
    host: 'c##xxx',
    user: 'xxxx',
    password: '120.79.238.xxx',
    database: 'orcl'
  }
});

executeRawQuery = function (SQL_QUERY) {

  return new Promise((resolve, reject) => {
    var data;
    try{
      console.log('executeRawQuery',SQL_QUERY);
      data = knex.select().from(knex.raw('(' + SQL_QUERY + ')'));
      resolve(data);
    }catch(err){
      console.log('fuck err ',err);
      reject(err);
    }
  });

};

var data = await executeRawQuery('SELECT x.ROWID,x.* FROM C##SCOTT120.XYC_SSO_ACCOUNT_STUDENT x WHERE rownum <= 300');

代码抛出错误

{ Error: ORA-12154: TNS:could not resolve the connect identifier specified
    at Client_Oracledb.acquireRawConnection (/Users/abc/Documents/projects/game/server/node_modules/knex/lib/dialects/oracledb/index.js:79:27)
    at create (/Users/abc/Documents/projects/game/server/node_modules/knex/lib/client.js:258:21)
    at utils_1.tryPromise (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:389:34)
    at Object.tryPromise (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/utils.js:53:24)
    at Promise (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:389:17)
    at new Promise (<anonymous>)
    at callbackOrPromise (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:380:12)
    at Pool._create (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:290:9)
    at Pool._doCreate (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:260:36)
    at Pool._tryAcquireOrCreate (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:211:18)
    at Pool.acquire (/Users/abc/Documents/projects/game/server/node_modules/tarn/lib/Pool.js:117:14)
    at Bluebird.try (/Users/abc/Documents/projects/game/server/node_modules/knex/lib/client.js:312:43)

0 个答案:

没有答案