-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I want to write a driver manager for oracle communication with node js. I have written the following code and have exported a singleton object. The issue is when I am trying to use a pool to get connection, it shows me there is no method called "c_pool.getConnection()".
Manager code
var c_oracle = require('oracledb');
var c_pool={};
class OracleManager{
constructor(p_host, p_port, p_user, p_passwd, p_dbname, p_maxconnections, p_debug){
c_oracle.createPool({
user: p_user,
password: p_passwd,
connectString: p_host+':'+p_port+'/'+p_dbname,
poolMax: 10,
poolMin: 0,
poolIncrement: 2,
poolTimeout: 10
},function(error,pool){
c_pool=pool;
});
}
this.getConnection = function(callback)
{
c_pool.getConnection(function(p_err, p_connection)
{
if(p_err)
{
c_logger.error("Error occured while fetching connection from the Oracle Pool " + c_mypoolid, p_err);
throw p_err;
}
else
{
c_logger.debug("invoking callback after getting connection");
callback(p_connection);
}
});
}
}
var oracle = new OracleManager(c_properties.get('oracle-db-host'), c_properties.get('oracle-db-port'), c_properties.get('oracle-db-username'), c_properties.get('oracle-db-password'), c_properties.get('oracle-db-dbname'), c_properties.get('oracle-db-maxconnections'), c_properties.get('oracle-db-debug'));
module.exports = oracle;