How to use the oracledb.createPool function in oracledb

To help you get started, we’ve selected a few oracledb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oracle / node-oracledb / examples / sessiontagging2.js View on Github external
async function init() {
  try {
    await oracledb.createPool({
      user: dbConfig.user,
      password: dbConfig.password,
      connectString: dbConfig.connectString,
      sessionCallback: initSession,
      poolMin: 1,
      poolMax: 4,
      poolIncrement: 1
    });

    // Create HTTP server and listen on port httpPort
    const server = http.createServer();
    server.listen(httpPort)
      .on('request', handleRequest)
      .on('error', (err) => {
        console.error('HTTP server problem: ' + err);
      })
github oracle / node-oracledb / examples / webapp.js View on Github external
function init() {
  oracledb.createPool(
    {
      user: dbConfig.user,
      password: dbConfig.password,
      connectString: dbConfig.connectString
      // edition: 'ORA$BASE', // used for Edition Based Redefintion
      // events: false, // whether to handle Oracle Database FAN and RLB events or support CQN
      // externalAuth: false, // whether connections should be established using External Authentication
      // homogeneous: true, // all connections in the pool have the same credentials
      // poolAlias: 'default', // set an alias to allow access to the pool via a name
      // poolIncrement: 1, // only grow the pool by one connection at a time
      // poolMax: 4, // maximum size of the pool. Increase UV_THREADPOOL_SIZE if you increase poolMax
      // poolMin: 0, // start with no connections; let the pool shrink completely
      // poolPingInterval: 60, // check aliveness of connection if idle in the pool for 60 seconds
      // poolTimeout: 60, // terminate connections that are idle in the pool for 60 seconds
      // queueTimeout: 60000, // terminate getConnection() calls in the queue longer than 60000 milliseconds
      // sessionCallback: myFunction, // function invoked for brand new connections or by a connection tag mismatch
github oracle / oracle-db-examples / javascript / node-oracledb / webapppromises.js View on Github external
function init() {
  oracledb.createPool({
    user: dbConfig.user,
    password: dbConfig.password,
    connectString: dbConfig.connectString
    // Default values shown below
    // externalAuth: false, // whether connections should be established using External Authentication
    // poolMax: 4, // maximum size of the pool. Increase UV_THREADPOOL_SIZE if you increase poolMax
    // poolMin: 0, // start with no connections; let the pool shrink completely
    // poolIncrement: 1, // only grow the pool by one connection at a time
    // poolTimeout: 60, // terminate connections that are idle in the pool for 60 seconds
    // poolPingInterval: 60, // check aliveness of connection if in the pool for 60 seconds
    // queueRequests: true, // let Node.js queue new getConnection() requests if all pool connections are in use
    // queueTimeout: 60000, // terminate getConnection() calls in the queue longer than 60000 milliseconds
    // poolAlias: 'myalias' // could set an alias to allow access to the pool via a name.
    // stmtCacheSize: 30 // number of statements that are cached in the statement cache of each connection
  })
    .then(function(pool) {
github oracle / node-oracledb / examples / webapppromises.js View on Github external
function init() {
  oracledb.createPool({
    user: dbConfig.user,
    password: dbConfig.password,
    connectString: dbConfig.connectString
    // edition: 'ORA$BASE', // used for Edition Based Redefintion
    // events: false, // whether to handle Oracle Database FAN and RLB events or support CQN
    // externalAuth: false, // whether connections should be established using External Authentication
    // homogeneous: true, // all connections in the pool have the same credentials
    // poolAlias: 'default', // set an alias to allow access to the pool via a name.
    // poolIncrement: 1, // only grow the pool by one connection at a time
    // poolMax: 4, // maximum size of the pool. Increase UV_THREADPOOL_SIZE if you increase poolMax
    // poolMin: 0, // start with no connections; let the pool shrink completely
    // poolPingInterval: 60, // check aliveness of connection if idle in the pool for 60 seconds
    // poolTimeout: 60, // terminate connections that are idle in the pool for 60 seconds
    // queueTimeout: 60000, // terminate getConnection() calls in the queue longer than 60000 milliseconds
    // sessionCallback: myFunction, // function invoked for brand new connections or by a connection tag mismatch
    // stmtCacheSize: 30 // number of statements that are cached in the statement cache of each connection
github oracle / node-oracledb / test / externalAuthentication.js View on Github external
it('5.4 can create pool', function(done){
    if(dbConfig.externalAuth){
      oracledb.createPool(
        dbConfig,
        function(err, pool){
          should.not.exist(err);
          pool.should.be.ok;

          pool.getConnection(function(err, connection){
            should.not.exist(err);
            connection.should.be.ok;

            sql = "select (1+4) from dual";
            connection.execute(
              sql,
              function(err, result){
                should.not.exist(err);
                (result.rows[0][0]).should.equal(5);
                connection.release( function(err){
github oracle / node-oracledb / test / sessionTag.js View on Github external
it('184.4.7 Close connection from pool with {drop: false}', async function () {
      let conn, pool;
      try {
        pool = await oracledb.createPool(dbconfig);
        conn = await pool.getConnection({tag: tag1});
        should.strictEqual(pool.connectionsOpen, 1);
        should.strictEqual(pool.connectionsInUse, 1);
      } catch (err) {
        should.not.exist(err);
      } finally {
        if (conn) {
          try {
            await conn.close({drop: false});
          } catch(err) {
            should.not.exist(err);
          } finally {
            should.strictEqual(pool.connectionsOpen, 1);
            should.strictEqual(pool.connectionsInUse, 0);
          }
        }
github oracle / node-oracledb / test / poolPing.js View on Github external
function(cb) {
        oracledb.createPool(
          dbConfig,
          function(err, pooling) {
            should.not.exist(err);
            pool = pooling;

            should.strictEqual(pool.poolPingInterval, userSetInterval);
            cb();
          }
        );
      },
      function(cb) {
github oracle / node-oracledb / test / checkClassesTypes.js View on Github external
function(callback) {
          oracledb.createPool(credentials, callback);
        },
        function(pool, callback) {
github OraOpenSource / orawrap / lib / poolmanager.js View on Github external
return raiseError(that.DEFAULT_POOL_NAME_USED);
            }

            if (that._poolCount === 1 && that.defaultPoolExists()) {
                return raiseError(that.FIRST_POOL_NOT_NAMED);
            }

            if (that._poolCount > 0 && !config.poolName) {
                return raiseError(that.POOL_NOT_NAMED);
            }

            if (that._poolMap[key]) {
                return raiseError(that.DUP_POOL_NAME);
            }

            oracledb.createPool(
                config,
                function(err, p) {
                    if (err) {
                        reject(err);

                        if (cb) {
                            cb(err);
                        }

                        return;
                    }

                    that._poolCount += 1;

                    p._poolName = key;