我尝试在每次调用中创建一个新的数据库对象,但仍然出现相同的错误。(因为变量范围不应该在每次调用中都是不同的对象吗?)
这是调用的函数。
exports.get_type = function(req, res ) {
var query=""; // in case we want to filter
if(req.query.term)
{
query=(req.query.term).toUpperCase();
}
var typeString=(req.params.type).toUpperCase();
var globals = require('C:/Program Files/nodejs/cache082');
var objdb = new globals.Cache();
objdb.open(
{
path:"D:/Program Files/Cache/mgr",
username: ruser,
password: rpwd,
namespace: rnsp
},
function(error, result){
if (!error) {
console.log('DB Open : Getting Dictionary Type list:'+typeString);
objdb.function({function:"getDic^UTIL", arguments:
[typeString,query]},function(error,dic){
var response = dic.result;
//send response
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.send(response);
});
}
else
{
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.send(500, { error: "Database Error" });
}
}); // ends
};