[Stackoverflow] [Progress OpenEdge ABL] how to use odbc-pool on Node.js project

Status
Not open for further replies.
H

Hiroshi l

Guest
Im trying to access a DSN on windows with a simple Node.js program that returns either a positive or a negative message. However, I keep getting the following message.

Code:
Error connecting to database: TypeError: Pool is not a constructor
    at checkConnection (C:\project\path\server.js:9:16)
    at Object.<anonymous> (C:\project\path\server.js:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47
Connection failed!


follows my full code:

Code:
const { Pool } = require('odbc-pool'); 

const connectionString = 'DSN=test-dsn-name';

async function checkConnection() {
    let pool;

    try {
        pool = new Pool(connectionString);
        console.log('Connection to OpenEdge database established successfully.');
        return true;
    } catch (error) {
        console.error('Error connecting to database:', error);
        return false;
    } finally {
        if (pool) {
            await pool.close();
        }
    }
}

checkConnection()
  .then(success => {
    if (success) {
        console.log('Connection successful!');
    } else {
        console.error('Connection failed!');
    }
  })
  .catch(error => console.error(error));

Im trying to get the data from a Progress OpenEdge database and use it in Node.js. This is the firs time I interact with both tools.

I properly installed node and the libraries im using in the program (npm install odbc and npm install odbc-pool), I believe that i properly set up the Progress ODBC as well since when i test connection it returns a positive message, however i consider that even the way im looking at the problem might be wrong.

Continue reading...
 
Status
Not open for further replies.
Top