Multiple database connection in single connection pool using Node JS
<p>I am trying to create a database connection pool in Node js using generic-pool package. With single database the pool is working fine but I want to use more than one database in single pool to be use. In this context I am facing issue. Generic pool is not creating pool for both the database in single pool. Below is my code. I am using trireme-jdbc for JDBC connection ang generic-pool for connection pooling.</p>

<pre><code>var Pool = require('C:JCI/trireme-jdbc/node_modules/generic-pool').Pool;
var jdbc = require('C:/Program Files/nodejs/node_modules/trireme-jdbc');
var configOpenedge = require('C:/Program Files/nodejs/node_modules/trireme-jdbc/testconf/config-openedge.js');
var configPostgre = require('C:/Program Files/nodejs/node_modules/trireme-jdbc/testconf/config-postgre.js');

                var pool = new Pool({
                    name : 'Anil-JCI',
                    create : function(callback) {
                        var connOpenedge = new jdbc.Database({
                            url : configOpenedge.url,
                            properties : configOpenedge.properties,

                        });

                        var connPostgre = new jdbc.Database({
                            url : configPostgre.url,
                            properties : configPostgre.properties,

                        /*
                         * minConnections : 1, maxConnections : 2000, idleTimeout : 60
                         */
                        });

                        callback(null, connOpenedge);

                    },


                    destroy : function(client) {
                        client.end();
                    },
                    max : 10,
                    // optional. if you set this, make sure to drain() (see step 3)
                    min : 2,
                    // specifies how long a resource can stay idle in pool before being removed
                    idleTimeoutMillis : 30,
                    // if true, logs via console.log - can also be a function
                    log : true

                });

                console.log("connection created");

                pool.acquire(function(err, clientOpenedge, clientPostgre) {
                    if (err) {
                        throw err;
                    }

                    else {
                        clientOpenedge.execute(
                                'select * from "po" where "po-num" = ? and "vend-num" = ? ', [
                                        4322452, 4301170 ], function(err, result, rows) {

                                    // pool.release(client);

                                    console.log(err);
                                    rows.forEach(function(row) {
                                        console.log(row);
                                    });
                                    console.log("Openedge Data Printed...");
                                });
                        clientPostgre.execute("select * from employees ",
                                [ ], function(err, result) {

                                    // pool.release(client);

                                    console.log("we are in postgre");
                                    console.log(result);
                                    console.log("Postgre Data Printed...");
                                });
                    }
                });
</code></pre>