NodeJS Connection Pooling

Refer: https://github.com/oracle/node-oracledb/blob/master/doc/api.md#connpoolcache

12.4.3 Connection Pool Cache
When pools are created, they can be given a named alias. The alias can later be used to retrieve the related pool object for use. This facilitates sharing pools across modules and simplifies getting connections.

Pools are added to the cache by using a poolAlias property in the poolAttrs object::

oracledb.createPool (
  {
    user: 'hr',
    password: mypw,  // mypw contains the hr schema password
    connectString: 'localhost/XEPDB1',
    poolAlias: 'hrpool'
  },
  function(err) {  // callback 'pool' parameter can be omitted
    . . . // get the pool from the cache and use it
  }
);

Leave a Reply