Oracle与node-oracle:在试图检索错误的文本时出错,ORA-01804。

时间:2022-12-13 12:45:25

I'm trying to use node-oracle to 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:

NodeJS代码:

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 node command.
  • 我还没有正确地设置env变量,这是我的第一个测试,因此是long node命令。
  • the paths are similar to those described but I removed the prefixes which would tie this to my company
  • 这些路径与所描述的路径相似,但我去掉了与公司相关的前缀

I've looked around the web and a lot of people point this to a poorly configured LD_LIBRARY_PATH variable. If I ls that folder I get:

我浏览了一下web,很多人将它指向一个配置不良的LD_LIBRARY_PATH变量。如果我打开文件夹,我得到:

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.

欢呼。

2 个解决方案

#1


2  

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

感谢@evenro,我在试图检索Error 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
  • ORACLE_HOME:指向oracle客户端basedir
  • LD_LIBRARY_PATH: point at the lib folder inside the client
  • 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.

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

#2


1  

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——符号链接r9机型~ /λ。邮政编码*

It worked! properly then.Hope it helps somebody.

它工作!正确。希望它能帮助别人。

#1


2  

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

感谢@evenro,我在试图检索Error 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
  • ORACLE_HOME:指向oracle客户端basedir
  • LD_LIBRARY_PATH: point at the lib folder inside the client
  • 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.

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

#2


1  

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——符号链接r9机型~ /λ。邮政编码*

It worked! properly then.Hope it helps somebody.

它工作!正确。希望它能帮助别人。