【发布时间】:2017-05-31 14:30:17
【问题描述】:
目前,我正在做一个需要在oracle 中完成后端的项目。我使用给定的link 并在我的mac 上使用npm 安装了node-oracledb。我的文件内容如下
var oracledb = require('oracledb');
oracledb.getConnection(
{
user : 'username',
password : 'password',
connectString : 'username/password//hostname:port/sid'
function(err, connection)
{
if (err) {
console.error(err.message);
return;
}else{
connection.execute(
"SELECT * from TableName",
function(err, result)
{
if (err) { console.error(err); return; }
console.log(result.rows);
});
}
});
当我运行 node filename.js 时出现以下错误
ORA-12154: TNS:could not resolve the connect identifier specified
我使用的节点版本是v7.0.0,npm 版本是v3.10.8。我的 oracle 数据库也是云上的 11g 实例。有人可以让我知道我做错了什么吗?
【问题讨论】:
-
我知道这个问题已经解决了,但我也面临着类似的问题。我遵循了 node-oracledb 中提到的方向。我已经安装了 instantclient basic 和 sdk 并设置了它们的路径。一旦我安装 oracle 11g express,我就会收到错误
oracledb module cannot be found。当我卸载 11g express 时,我收到错误ORA-12541: TNS:no listener。您能否指导我如何安装 11g 以及我的连接字符串是什么?
标签: javascript node.js oracle oracle11g npm