Failed to create Node pool connection

Asked

Viewed 251 times

0

I am trying to open a connection pool using the oracledb module but I get an Exception when trying to create the pool

import OracleDB from 'oracledb'
import dotenv from 'dotenv'

OracleDB.outFormat = OracleDB.OUT_FORMAT_OBJECT

dotenv.config()

export class BaseConnection {
  public connection: OracleDB.Connection
  public connectionPool: OracleDB.Pool

  public async openConnection (): Promise<void> {
    try {
      this.connectionPool = await OracleDB.createPool({
        user: process.env.DB_USER,
        password: process.env.DB_PASSWORD,
        connectString: process.env.DB_CONNECTION_STRING
      })
      this.connection = await this.connectionPool.getConnection()
      console.log('Banco de dados conectado com sucesso')
    } catch (error) {
      console.log(error)
    }
  }
}

error

{ Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "Não foi possível encontrar o módulo especificado". See https://oracle.github.io/odpi/doc/installation.html#windows for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in your PATH environment variable.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/winx64soft-089540.html
A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.

    at OracleDb.createPool (C:\Proc-evandro\ph\node_modules\oracledb\lib\oracledb.js:180:8)

2 answers

0

Friend, this error that is returning does not explain which error in connection with the BD.
This error is displayed when you have an error that is not being handled, so first you should treat this error, so it starts to be displayed what the problem is actually when creating the pool.
As you are utlizando await can capitulate error with Try catch when creating pool, so:

try{
  this.connectionPool = await oracledb.createPool({
        user: process.env.DB_USER,
        password: process.env.DB_PASSWORD,
        connectString: process.env.DB_CONNECTION_STRING
  })
} catch (err) {
  console.log(err);
}

That way, when there is error when creating the pool, it will be treated in catch and your console will be displayed the same.
If the error output is not enough for you to resolve the problem with the connection, edit your question and include this new information so we can help you.

  • I made the change and I received this other error, details I am connecting to a database via VPN, I have another application in Node without typescript that I use the same database via pool conection and I do not get this error message.

  • @Evandroignacio, have you noticed that now the error is talking about the 64bit architecture? He even made the procedures informed by the error himself installing the library in 64bits?

  • yes, the host machine already has this configuration, I use the same module in another application Node without typescript and the pool is created without errors, I do not understand why I get this error here

  • @Evandroignacio, one thing you should also notice is that in this application you installed the nodedb module locally and not global, see by the error description the path C:\Proc-evandro\ph\node_modules\oracledb\lib\oracledb.js:180:8, that is, if the oracledb this location it should not be "reaching" the Oracle Client Libraries, probably in the other projects you used this global module, I suggest that a read on how should be used/ configured the oracledb here

-1

I faced the same hindrance when climbing a project in the client environment. oracledb uses the 64-bit client to connect in the bank. In my case it was enough to install the client available on the oracle website that worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.