oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.26k stars 1.08k forks source link

Getting error Error: "DPI-1047: Cannot locate a 64-bit Oracle Client library #1078

Closed johnysv closed 5 years ago

johnysv commented 5 years ago

I am trying to connect Oracle DB (linux) from node.js(some other machine). but getting the below error.

Telnet for the db port works fine. Able to query through sqldeveloper.

"Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found" node js"

anthony-tuininga commented 5 years ago

That error implies that you are running 64-bit Node.js but you have a 32-bit Oracle Client library. You can run the file command on oracledb.node and on libclntsh.so to verify. Check environment variable LD_LIBRARY_PATH and the contents of /etc/ld.so.conf.d to see which library is being loaded.

johnysv commented 5 years ago

Do you mean that I need to install Oracle client lnstant client in my machine where I have node.js? My actual db is in some other linux remote server .

anthony-tuininga commented 5 years ago

Yes, you need to install the Oracle Client libraries (such as Instant Client) in the machine where you are running Node.js.

johnysv commented 5 years ago

I installed Instant client 18_5 (added to PATH). I also found vs redistributable is already installed (which u can see in screen shot). But now I get the below error

"{ Error: ORA-12154: TNS:could not resolve the connect identifier specified errorNum: 12154, offset: 0 }"

Please help me resolve this.

image

anthony-tuininga commented 5 years ago

That error means that your installation is working. What connect string are you using? There are two general formats:

1) a simple string which is looked up in $TNS_ADMIN/tnsnames.ora (or a specific location if the environment variable is not specified)

2) an EZ connect string in the format host[:port]/service such as localhost/DB18

Of the two, I'd suggest the latter as it is easier to use, but if your environment has tnsnames set up that will work as well.

If you can provide the code you are using and the full connect string we might be able to help further. Just mask the user name and password with <user> and <password> or some such.

johnysv commented 5 years ago

Here is my code

var mypw = "*****"

var oracledb = require('oracledb');
oracledb.getConnection(
  {
    user          : "u_name",
     password      : mypw,
     connectString : "jdbc:oracle:thin:@10.90.103.4:1521:cita"
  },
  function(err, connection)
  {
    if (err) { console.error(err); return; }
    connection.execute(
      `select name from CLE_EXCEPTIONRECORD where CORRELATIONID='983b2f58-e0eb-49cb-b76c-9b8107de3edc'`,
      function(err, result)
      {
        if (err) { console.error(err); return; }
        console.log(result.rows);
      });
  });

Also see the below screen shot taken from sqldeveloper image

Below is the screen shot from developer tool TIBCO

image

anthony-tuininga commented 5 years ago

That's helpful. You can't use the JDBC thin driver with node-oracledb. So instead of this connect string:

jdbc:oracle:thin:@10.90.103.4:1521:cita

use this connect string

10.90.103.4:1521/cita

or, since port 1521 is the default anyway, just

10.90.103.4/cita

johnysv commented 5 years ago

Hi,

Thanks, I guess I get some output. But the Output is not understandable. Please see the below output.

[ Lob { _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 2, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: true, iLob: [Object], close: [Function] } ],

image

But when I query the same in putty, I get the correct column value.

image

anthony-tuininga commented 5 years ago

The default behaviour when fetching a CLOB or BLOB value is to return a LOB object, which allows for streaming. If you know the size of the CLOB and BLOB are reasonably small (a few megabytes) it is far easier to return them as plain strings and buffers. You can do that by adding the following code:

oracledb.fetchAsString = [oracledb.CLOB];

You can see a full example here.

cjbj commented 5 years ago

@johnysv you seem to have missed our installation documentation and our userguide. Have a scan through those.