-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Closed
Copy link
Labels
Description
1. Oracle SQL Version: 23.1.1.345
2. Describe the problem:
Recently I'm configuring Oracle SQL Databse with node.js.
I'm trying to verify alive db connection.
This is my db connection sample query:
import * as oracledb from 'oracledb';
export class OracleSQL {
private static conn;
static async connect() {
this.conn = await oracledb.getConnection({
connectString: "host:port/schema",
user : "username",
password : "********"
});
// TODO: add some condition to verify database connected successfully
// if (connection is established) {
console.log('Database connected successfully');
return true;
// }
}
static async query(queryStr) {
// TODO: add some condition to verify connection is still alive or not
if (!this.conn) {
let res = await this.connect()
if (res) {
return await this.conn.execute(queryStr);
}
} else {
return await this.conn.execute(queryStr);
}
}
static async close() {
// TODO: add some condition to verify connection already established or not
// if (connection is established) {
await this.conn.close()
.then(() => {
console.log('Database disconnected successfully');
this.conn = null;
return true;
});
// }
}
}I want to add objective, my connection is already established(alive) or not.
There should be some this.conn object's key or function which should return a Boolean value for connection alive validation
- Related StackOverflow Question: https://stackoverflow.com/questions/78670590/is-there-any-way-to-verify-oracle-sql-database-connection-and-error-handling