DB Connection close issue in Node.js using trireme-jdbc

Not applicable

I have developed and deployed a Node.js application in apigee, which performs few CRUD operations. To establish db connection I have used trireme-jdbc module of node.js. I am able to perform all CRUD operations well through trireme-jdbc but I have problem with DB session close using db.close() function in trireme-jdbc. When I use db.close() it do not close currently active/open session from the pool. I want to know is there any other process or way to close db connection perfectly. Also I want to close all active connections from pool.

Any help will be appreciated. Below is the sample code to establish connection, run a select query and used db.close() to close session. My database is Openedge/Progress.

var jdbc = require('trireme-jdbc');
var db = new jdbc.Database({
      url : connectionURL, 
      properties: {
        user: 'XXXXXX',
        password: 'XXXXXX',
      },
      minConnections:1,
      maxConnections:2,
      idleTimeout:10
    });
db.execute('select * from users ', function(err, result, rows) {
  console.log(err);
  console.log(result);
  rows.forEach(function(row) {
    console.log(row);
  });
  db.close();   // Used to close DB session/connection.
});

0 2 1,294
2 REPLIES 2

Not applicable

This code will not work well. If the "close" function immediately closes all connections, then it is very likely, that the previous query will not be finished, when the connection is closed.

How do you know the close is not occurring? Have you tried using a setTimeout() ? like so:

db.execute('select * from users ', function(err, result, rows) {
  console.log(err);
  console.log(result);
  rows.forEach(function(row) {
    console.log(row);
  });
  setTimeout(function(){ db.close(); }, 1);
});