Установка наименования подуля в сессии при подключении к БД

This commit is contained in:
Mikhail Chechnev 2018-11-14 10:05:08 +03:00
parent d26b0d49c8
commit d98fd1046a
4 changed files with 18 additions and 11 deletions

View File

@ -15,7 +15,9 @@ let dbConnect = {
password: "parus", password: "parus",
//Строка подключения к БД //Строка подключения к БД
connectString: "DEMOP_CITKSERV_WAN", connectString: "DEMOP_CITKSERV_WAN",
//Модуль обслуживания БД //Наименование модуля (для сессии БД)
moduleName: "PARUS$ExchangeServer",
//Подключаемый модуль обслуживания БД (низкоуровневые функции работы с СУБД)
module: "parus_oracle_db.js" module: "parus_oracle_db.js"
}; };

View File

@ -87,7 +87,8 @@ class DBConnector {
this.connection = await this.connector.connect( this.connection = await this.connector.connect(
this.connectSettings.user, this.connectSettings.user,
this.connectSettings.password, this.connectSettings.password,
this.connectSettings.connectString this.connectSettings.connectString,
this.connectSettings.moduleName
); );
return this.connection; return this.connection;
} catch (e) { } catch (e) {

View File

@ -35,6 +35,7 @@ try {
a.putLog(db.MSG_TYPE_INF, "Сервер приложений подключен") a.putLog(db.MSG_TYPE_INF, "Сервер приложений подключен")
.then(res => { .then(res => {
console.log(res); console.log(res);
setTimeout(() => {
a.disconnect() a.disconnect()
.then(res => { .then(res => {
console.log("DISCONNECTED"); console.log("DISCONNECTED");
@ -42,6 +43,7 @@ try {
.catch(e => { .catch(e => {
console.log(e.code + ": " + e.message); console.log(e.code + ": " + e.message);
}); });
}, 10000);
}) })
.catch(e => { .catch(e => {
console.log(e.code + ": " + e.message); console.log(e.code + ": " + e.message);

View File

@ -38,13 +38,14 @@ const SLOG_STATE_ERR = "ERR"; //Ошибка (строковый код)
//------------ //------------
//Подключение к БД //Подключение к БД
const connect = async (user, password, connectString) => { const connect = async (user, password, connectString, moduleName) => {
try { try {
const conn = await oracledb.getConnection({ const conn = await oracledb.getConnection({
user, user,
password, password,
connectString connectString
}); });
conn.module = moduleName;
return conn; return conn;
} catch (e) { } catch (e) {
throw new Error(e.message); throw new Error(e.message);
@ -174,9 +175,10 @@ const getQueueOutgoing = (connection, portionSize) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (connection) { if (connection) {
connection.execute( connection.execute(
"BEGIN PKG_EXS.QUEUE_OUT_GET(NPORTION => :NPORTION, RCQUEUES => :RCQUEUES); END;", "BEGIN PKG_EXS.QUEUE_GET(NPORTION => :NPORTION, NSRV_TYPE => :NSRV_TYPE, RCQUEUES => :RCQUEUES); END;",
{ {
NPORTION: portionSize, NPORTION: portionSize,
NSRV_TYPE: NSRV_TYPE_SEND,
RCQUEUES: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } RCQUEUES: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OBJECT, autoCommit: true, fetchInfo: { BMSG: { type: oracledb.BUFFER } } }, { outFormat: oracledb.OBJECT, autoCommit: true, fetchInfo: { BMSG: { type: oracledb.BUFFER } } },