【发布时间】:2017-05-25 22:26:34
【问题描述】:
我正在尝试将 oracle 与 NodeJS 连接。步骤如下。先决条件除了NodeJS(0.10.25)和npm(1.3.24)外没有安装客户端。
在我的 ExpressJS 项目中:
npm install db-oracle
安装时没有发现错误。-
在 app.js 中
var oracle = require('db-oracle'); var connString = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxx)))"; var connectData = { "tns": connString, "user": "XPPS_OWNER", "password": "Ex3ec" }; -
在我这样编码的端点之一中,
app.get('/oracleendpoint',function(req,res){ connectData.connect(function(error) { if (error) { return console.log("CONNECTION ERROR: " + error); } this.query().select('*').from('Users').execute(function(error, rows) { if (error) { return console.log('ERROR: ' + error); } console.log(rows.length + ' ROWS'); }); }); });
预期的输出是连接数据库。
仅供参考:数据库实例运行良好。
查询:
- 数据库名称是什么?
-
它显示如下所示的错误。造成这种情况的根本原因是什么?
module.js:340 throw err; ^ Error: Cannot find module './build/Release/oracle_bindings' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (C:\xampp\htdocs\mytest\node_modules\db-oracle\db-oracle.js:18:15) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)
请让我知道任何缺失或需要安装或需要任何节点模块或代码更改。我用谷歌搜索但徒劳无功。没有找到该错误的正确文档。
【问题讨论】:
-
上述文件夹中是否有文件
oracle_bindings?您是否按照包装上的说明进行操作? npmjs.org/package/db-oracle -
没有名为 oracle_bindings 的文件,由于我在 windows 系统上工作,我没有按照说明进行操作,我的要求是只需要连接数据库。甚至 oracle 也没有安装在我的本地系统中。它在远程系统中。
-
很抱歉,但连接到 Oracle 数据库是一项艰巨的任务(这里没有讽刺意味),并且如果您的服务器上至少没有 Oracle 客户端库,则永远不会机器安装。此外,我认为这个库甚至不会在 Windows 系统上编译,也许看看node-oracle