Connect Local NodeJS Application to a Docker Oracle Database

Issue

This Content is from Stack Overflow. Question asked by Pedro Castro

I’m Trying to connect my local NodeJS application to my Oracle database which is in a Docker container. Here is my index.js

const express = require('express');
const oracledb = require('oracledb');
const app = express();

oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;

async function conexion(){
    let conexion;

    try{
        conexion = await oracledb.getConnection({
            user                :"myuser",
            password            :"123456",
            connectString       :"172.17.0.2/ORCLCDB" //this is the IP of the docker container
        });

        const data = await conexion.execute(
            'SELECT * FROM Pais',
        );
        console.log(data.rows);
    } catch(err){
        console.error(err);
    }
}

app.use(express.json());


var port = process.env.PORT || 8080 
conexion();

app.listen(port)
console.log('API escuchando en el puerto ' + port)

But I get this error when running my NodeJS app:


API escuchando en el puerto 8080
Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/node-oracledb/INSTALL.html for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle Client libraries configured with ldconfig, or in LD_LIBRARY_PATH.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from 
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async conexion (/home/pedrocastro/Universidad/2S-2022/BASES1/Proyecto1_API/index.js:11:20) {
  errorNum: 0,
  offset: 0
}

How can I solve this??



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?