【发布时间】:2015-05-25 14:27:33
【问题描述】:
我正在构建一个将连接到 Oracle 数据库的 NodeJS 应用程序。
我想知道如果我不关闭连接并且我多次调用fiftycent() 函数会发生什么?
var i=50;
function fiftycent() {
var oracledb = require('oracledb');
oracledb.getConnection(
{
user : "hr",
password : "welcome",
connectString : "localhost/XE"
},
function(err, connection)
{
if (err) {
console.error(err.message);
return;
}
connection.execute(
"SELECT department_id, department_name "
+ "FROM departments "
+ "WHERE department_id = :did",
[180],
function(err, result)
{
if (err) {
console.error(err.message);
return;
}
console.log(result.rows);
});
});
i=i-1;
if (i>0) fiftycent();
}
节点服务器运行几天后,会不会导致内存故障之类的?
请注意,此示例的部分内容来自https://github.com/oracle/node-oracledb,它们不包括
connection.release( function(err){
if (err) console.error(err.message);
});
在他们的代码中。
提前感谢您的回答。
【问题讨论】: