i'm trying to implement oracle connection using Typescript ES6 Class module.
i have installed @types/oracledb package as well as oracledb package. Jasmin framework is used.
Below are my code which i have implemented.
import * as oracledb from 'oracledb';
export class ConnectionDAO{
/**
* Connection Variable Declaration
*/
conn;
/**
* Result Variable Declaration
*/
result;
/**
*
* Creates an instance of CommercialDAO.
* To Initiate Connection and Make the connection utilized by @memberof CommercialDAO
* @memberof CommercialDAO
*/
constructor() {
this.conn = oracledb.getConnection({
user: "commercial",
password: "oracle",
connectString: "localhost/COMMERCIALDB"
});
}
public getRwCnt() {
return new Promise(async function(resolve, reject) {
try {
let result = this.conn.execute('SELECT TESTCASEID FROM EXECUTE_TESTCASE');
resolve(this.result.rows.length);
} catch (err) { // catches errors in getConnection and the query
reject(err);
}
this.conn.release();
});
}
}
Error:
TypeError: this.conn.execute is not a function
But in this code connection itself not getting stored in 'this.conn' variable.
is there anyway to avoid promises and async function? Is there any other solution to achieve this? Please provide you valuable solution and suggestions. Expecting sample snippet.