Error: NJS-047: poolAlias "default" not found in the connection pool cache
Error: NJS-047: poolAlias "default" not found in the connection pool cache
you gave no code example which is really not the best way to get help, but I guess you did oracledb.getPool() before creating any pool.
See pool cache for instructions how to properly use the pool cache
https://github.com/oracle/node-oracledb/blob/master/doc/api.md#connpoolcache
///////////////////////////
// CREATE CONNECTION POOL//
///////////////////////////
oracle_db.init = function(callback) {
logger.info("initializing oracle db pool...");
oracledb.createPool(config.ORACLE, function(err, pool) {
if (err) {
logger.error("Failed to create oracle db pool..." + pool.poolAlias);
callback(err);
} else {
callback();
}
});
};
oracle_db.doConnect = function(getConnectionCb) {
var maxRetries = 3;
pool = oracledb.getPool(config.ORACLE.poolAlias);
try {
console.log(pool._logStats());
} catch (err) {}
async.retry(maxRetries, function(cb) {
pool.getConnection(function(err, conn) {
if (err) {
logger.error("Failed to create connection...");
cb(err);
return;
}
conn.execute('select 1 from dual', function(err, result) {
if (err) {
logger.error("Invalid Connection...");
conn.release(function() {
cb(err);
});
} else {
cb(null, conn);
}
});
});
}, function(err, conn) {
if (err) {
getConnectionCb(err);
} else {
getConnectionCb(null, conn);
}
});
};
you sure you called the doConnect after the init callback was called?
did the init callback return an error (in which case you don't have a pool set for that alias)?
Yes I called after init callback init callback didn't get any error
strange. hard to tell without seeing stack trace and knowing what is in that config.
just for sake of testing, can you put in your config:
js
poolAlias: 'test'
also for future I suggest you use code blocks when pasting code so it would be easy to read it.
///////////////////////////
// CREATE CONNECTION POOL//
///////////////////////////
oracle_db.init = function(callback) {
logger.info("initializing oracle db pool...");
oracledb.createPool(config.ORACLE, function(err, pool) {
if (err) {
logger.error("Failed to create oracle db pool..." + pool.poolAlias);
callback(err);
} else {
callback();
}
});
};
oracle_db.doConnect = function(getConnectionCb) {
var maxRetries = 3;
pool = oracledb.getPool(config.ORACLE.poolAlias);
try {
console.log(pool._logStats());
} catch (err) {}
async.retry(maxRetries, function(cb) {
pool.getConnection(function(err, conn) {
if (err) {
logger.error("Failed to create connection...");
cb(err);
return;
}
conn.execute('select 1 from dual', function(err, result) {
if (err) {
logger.error("Invalid Connection...");
conn.release(function() {
cb(err);
});
} else {
cb(null, conn);
}
});
});
}, function(err, conn) {
if (err) {
getConnectionCb(err);
} else {
getConnectionCb(null, conn);
}
});
};
Found The Solution, Should wait for 2 mins after Creation Of the Pool, It's working fine after.
That is not a solution. My guess is that you are not waiting for the pool creation callback
For anyone (else) reading this, don't forget that createPool() is async.
This issue gave me heartburn
Most helpful comment
That is not a solution. My guess is that you are not waiting for the pool creation callback