
nodejs中怎么判断oracledb连接是否断开
1个回答
展开全部
尝试获取数据,如果报错,特别是报连接断开的错误,则表明已经断开
router.get('/', function (req, res, next) { var oracledb = require('oracledb');
oracledb.getConnection(
{
user: 'username',
password: 'password',
connectString: '192.168.20.10:1521/ORCL'
}, function (err, connection) { if (err) {
console.error(err.message); return;
}
connection.execute( "SELECT * from CMS_FIlE where content_id=:id",
[1072], // bind value for :id
function (err, result) { if (err) {
console.error(err.message); return;
}
res.render('index', {title: '查询信息:' + JSON.stringify(result.rows)});
});
});
});
router.get('/', function (req, res, next) { var oracledb = require('oracledb');
oracledb.getConnection(
{
user: 'username',
password: 'password',
connectString: '192.168.20.10:1521/ORCL'
}, function (err, connection) { if (err) {
console.error(err.message); return;
}
connection.execute( "SELECT * from CMS_FIlE where content_id=:id",
[1072], // bind value for :id
function (err, result) { if (err) {
console.error(err.message); return;
}
res.render('index', {title: '查询信息:' + JSON.stringify(result.rows)});
});
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询