我创建了一个异步的executeQuery功能,能够让如果有的话,它被称为 一个循环中,下一个查询等待前一个完成之前被执行异步执行查询。 doCreatePool函数在程序初始化时被调用一次。 它创建一个连接池并将其保存在全局变量config.Oracle_POOL中,以便连接池保持活动状态,即使在doCreatePool返回之后,连接池也仍然存在,即 。联接游泳池和ORA-01000
Socket.io事件调用ExecuteQuery来执行查询(循环中的一个或多个)。
一切正常,但后查询一定量的执行, 我得到一个ORA-1000错误:“错误:ORA-01000:最大打开的游标超出” 要么选择,更新和插入查询。
通常连接池应该避免这个问题?
什么是我的代码中的黄?
doCreatePool(); //Create a connexion pool and save it in config.Oracle_POOL
//dbConfig={....}
function doCreatePool() {
dbConfig=config.Settings.DataBaseConnexionString;
oracle.createPool (
{
user : dbConfig.user,
password : dbConfig.password,
connectString : dbConfig.connectString,
poolMax : 44,
poolMin : 2,
poolIncrement : 5,
poolTimeout : 4
},
function(err, pool)
{
if (err) {
console.error("createPool() callback: " + err.message);
return;
} else {
config.Oracle_POOL = pool;
}
});
}
function ExecuteQuery(Query, LstParam, callBack) {
config.Oracle_POOL.getConnection(function(err, connection) {
if (err){
console.log("Oracle connexion pool --> err --> ", err);
if (connection)
connection.release(
function(err) {
if (err) {
console.log("(1) connection.release --> err--> ",err)
}
}
);
callBack(err, { rows : [] });
} else {
var OracleQueryOptions={outFormat: oracle.OBJECT, maxRows : 500, autoCommit : true};
connection.execute(Query, LstParam, OracleQueryOptions , function(err, results) {
if (!err) {
console.log("* connection.execute --> err--> ",err, "Query --> ", Query);
}
connection.release(function(err2) {
if (err2) {
console.log("(2) connection.release --> err-->",err)
}
callBack(err, results);
}
);
});
}
});
}