带有 node-oracle 的 Oracle:尝试检索错误 ORA-01804 的文本时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23060594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:19:22  来源:igfitidea点击:

Oracle with node-oracle: Error while trying to retrieve text for error ORA-01804

node.jsoracle

提问by bitoiu

I'm trying to use node-oracleto connect to a Oracle 11g database in UNIX. I can connect fine to the database using TOAD, but now I want to do application queries and this is what I did:

我正在尝试使用node-oracle连接到 UNIX 中的 Oracle 11g 数据库。我可以使用 TOAD 很好地连接到数据库,但现在我想做应用程序查询,这就是我所做的:

NodeJS code:

节点代码:

var oracle = require('oracle');

var connectData = {
  hostname: "host.com",
  port: 1521,
  database: "DB0000",
  user: "me",
  password: "password"
}

oracle.connect(connectData, function(err, connection) {
  if (err) { console.log("Error connecting to db:", err); return; }

  connection.execute("SELECT systimestamp FROM dual", [], function(err, results) {
    if (err) { console.log("Error executing query:", err); return; }

    console.log(results);
    connection.close();
  });
});

Then I this command on the unix box:

然后我在unix框上运行这个命令:

sh-3.2$ OCI_LIB_DIR= /oracle/client/v11.2.0.2-64bit/client_1/lib/ OCI_INCLUDE_DIR=/client/v11.2.0.2-64bit/client_1/rdbms/public/ OCI_HOME=/oracle/clien
t/v11.2.0.2-64bit/client_1/ NLS_LANG=.UTF8 LD_LIBRARY_PATH=/client/v11.2.0.2-64bit/client_1/lib/ /bin/node app.js

I get the following error:

我收到以下错误:

terminate called after throwing an instance of 'oracle::occi::SQLException'
  what():  Error while trying to retrieve text for error ORA-01804

Some notes:

一些注意事项:

  • I haven't set up env variables properly yet, this was my first test, thus the long nodecommand.
  • the paths are similar to those described but I removed the prefixes which would tie this to my company
  • 我还没有正确设置 env 变量,这是我的第一次测试,因此是长node命令。
  • 路径与描述的路径相似,但我删除了将其与我的公司联系起来的前缀

I've looked around the web and a lot of people point this to a poorly configured LD_LIBRARY_PATHvariable. If I lsthat folder I get:

我环顾了整个网络,很多人指出这是一个配置不当的LD_LIBRARY_PATH变量。如果我ls是那个文件夹,我会得到:

acfslib.pm          libclient11.a      libgnsjni11.so     libmm.a        libntcpaio11.so        liboraz.a          libsql11.a          naect_std.o.dbl             sscoreed.o
acfsroot.pl         libclntsh.so       libhasgen11.so     libn11.a       libntcps11.a           liborion11.a       libsqlplus.a        naedhs.o                    stubs
acfstoolsdriver.sh  libclntsh.so.10.1  libheteroxa11.so   libnbeq11.a    libntcps11_std.a.dbl   libowm2.so         libsqlplus.so       naeet.o                     sysliblist
activation.jar      libclntsh.so.11.1  libimf.a           libncrypt11.a  libntns11.a            libplc11.a         libsqora.so.11.1    naeet_std.o.dbl             transx.zip
classgen.jar        libclntst11.a      libintlc.so.5      libnhost11.a   libnus11.a             libplc11_pic.a     libsrvm11.so        nautab.o                    xmlcomp2.jar
clntsh.map          libclsra11.so      libipgo.a          libnjni11.so   libnzjs11.a            libplp11.a         libsrvmhas11.so     nautab_std.o.dbl            xmlcomp.jar
facility.lis        libcommon11.a      libipp_bz2.a       libnl11.a      libocci11.a            libplp11_pic.a     libsrvmocr11.so     nigcon.o                    xml.jar
jcr-1.0.jar         libcore11.a        libippcore.a       libnldap11.a   libocci.so             libpls11.a         libsvml.a           nigtab.o                    xmlmesg.jar
jdev-rt.zip         libcorejava.so     libippdcemerged.a  libnls11.a     libocci.so.11.1        libpls11_pic.a     libuini11.so        nnfgt.o                     xmlparserv2.jar
lclasses12.zip      libcxaguard.so.5   libippdcmerged.a   libnnet11.a    libocijdbc11.so        libpsa11.a         libunls11.a         ntcontab.o                  xmlparserv2_jaxp_services.jar
lclasses14.zip      libdbcfg11.so      libippsemerged.a   libnnetd11.a   libocr11.so            librdjni11.so      libvsn11.a          ojcr.jar                    xmlparserv2_sans_jaxp_services.jar
ldflags             libeons.so         libippsmerged.a    libnnz11.a     libocrb11.so           libskgxn2.so       libvsn11_std.a.dbl  oraclexsql.jar              xschema.jar
ldflagsO            libexpat.a         libipp_z.a         libnnz11.so    libocrutl11.so         libskgxp11.so      libwwg.a            osds_acfslib.pm             xsqlserializers.jar
libagent11.a        libexpat.la        libirc.a           libnoname11.a  liboevm.a              libskgxpcompat.so  libxdb.so           osds_acfsroot.pm            xsu12.jar
libagfw11.so        libexpat.so        libldapclnt11.a    libnque11.so   libons.so              libskgxpd.so       libxml11.a          osds_unix_linux_acfslib.pm
libagtsh.so         libexpat.so.1      libldapjclnt11.a   libnro11.a     libonsx.so             libskgxpg.so       libzt11.a           osntabst.o
libagtsh.so.1.0     libexpat.so.1.5.2  libldapjclnt11.so  libnsgr11.a    liborabz2.a            libskgxpr.so       libztkg11.a         s0main.o
libasmclntsh11.so   libgeneric11.a     liblxled.a         libnsslb11.a   liborasdkbase.so.11.1  libslax11.a        mail.jar            schagent.jar
libcell11.so        libgns11.so        liblzopro.a        libntcp11.a    liborasdk.so.11.1      libsnls11.a        naect.o             scorept.o

Any help would be greatly appreciated.

任何帮助将不胜感激。

I've looked at these question, but although similar I couldn't troubleshoot my problem with them:

我看过这些问题,但虽然相似,但我无法解决我的问题:

Cheers.

干杯。

回答by bitoiu

Thanks to @evenro, I went back to look at Error while trying to retrieve text for error ORA-01804and tried setting the ORACLE_HOMEenvironment variable.

感谢@evenro,我在尝试检索错误 ORA-01804 的文本时返回查看Error并尝试设置ORACLE_HOME环境变量。

It worked, but then I started checking which variables I really needed, so in the end I only used:

它奏效了,但后来我开始检查我真正需要哪些变量,所以最后我只使用了:

  • ORACLE_HOME: pointing at the oracle client basedir
  • LD_LIBRARY_PATH: point at the lib folder inside the client
  • ORACLE_HOME:指向oracle客户端basedir
  • LD_LIBRARY_PATH:指向客户端内部的lib文件夹

This is how it worked in the end:

这就是它最终的工作方式:

ORACLE_HOME=/somefolder/oracle/client/v11.2.0.2-64bit/client_1/ LD_LIBRARY_PATH=/somefolder/oracle/client/v11.2.0.2-64bit/client_1/lib/ node app.js

Thank you again for all the help in the comments, much appreciated.

再次感谢您在评论中的所有帮助,非常感谢。

回答by Sayed Zainul Abideen

In my case I solved it like this for python

在我的情况下,我为python解决了这个问题

I solved this by simply zipping the files properly with the symbolic links

我通过简单地使用符号链接正确压缩文件来解决这个问题

First I created three symbolic links :

首先我创建了三个符号链接:

ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so.1

ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so.1

ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so

ln -s ./lib/libaio.so.1.0.1 ./lib/libaio.so

ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1

ln -s ./lib/libaio.so.1.0.1 ./libaio.so.1.0.1

ln -s ./lib/libclntsh.so.12.1 ./lib/libclntsh.so

ln -s ./lib/libclntsh.so.12.1 ./lib/libclntsh.so

then I was zipping it incorrectly I did it like this:

然后我错误地压缩了它,我是这样做的:

zip --symlinks -r9 ~/lamda.zip *

zip --symlinks -r9 ~/lamda.zip *

It worked! properly then.Hope it helps somebody.

有效!那么正确。希望它可以帮助某人。