Commit 06ad2fba authored by Ajit Deshmukh's avatar Ajit Deshmukh

Closed the open connections.

parent 491e6f9a
......@@ -2302,12 +2302,15 @@
BaseLogger.log("3", null, null, "executeAndLog inputSql: [" + inputSql + "]");
BaseLogger.log("3", null, null, "executeAndLog execRights: [" + execRights + "]");
BaseLogger.log("3", null, null, "executeAndLog schemaName: [" + schemaName + "]");
try {
try {
conn = connDriver1.getConnectDB("Driver");
} catch (Exception e) {
System.out.println("Catch block for connection failed...." + e.getMessage());
String error = e.getMessage();
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error, "");
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error,
"");
return; // Stop execution if connection fails
}
// Changes by Ajit D. on 08-JUNE-26 for the query execution schema name fetched
......@@ -2356,16 +2359,18 @@
} else {
try{
try {
connForSchema = connDriverForSchema.getConnectDB(schemaName);
}catch (Exception e) {
} catch (Exception e) {
String error = (e.getMessage() != null)
? e.getMessage()
: e.toString();
System.out.println("Catch block for executeAndLog method for creating connection 1...." + error);
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error, "");
System.out
.println("Catch block for executeAndLog method for creating connection 1...." + error);
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm,
error, "");
return;
}
System.out.println(
......@@ -2391,6 +2396,8 @@
null,
"Actual Oracle USER : ["
+ schemaForPlaceHolder + "]");
schemaForRs.close();
schemaForPs.close();
}
if (schemaName.equalsIgnoreCase("APPVIS") || schemaName.equalsIgnoreCase("APPVISQC")) {
......@@ -2430,20 +2437,22 @@
System.out.println("execSchema:: " + execSchema);
System.out.println("enterpriseCode:: " + enterpriseCode);
//Comment out this part as for creating connection for Live schema does not need to use schema_name value instead use db_main value directly[26-June-2026]
// Comment out this part as for creating connection for Live schema does not
// need to use schema_name value instead use db_main value
// directly[26-June-2026]
// 1. Get the Connection String for the Main Execution
/*
String connForExecSql = "select schema_name from enterprise where enterprise = ?";
PreparedStatement connForExecPstmt = conn.prepareStatement(connForExecSql);
connForExecPstmt.setString(1, enterpriseCode);
ResultSet connForExecRs = connForExecPstmt.executeQuery();
while (connForExecRs.next()) {
System.out.println(
"EXECUTION CONNECTION USER ::: "
+ connForExecRs.getString(1));
connForExec = connForExecRs.getString("schema_name");
}
* String connForExecSql =
* "select schema_name from enterprise where enterprise = ?";
* PreparedStatement connForExecPstmt = conn.prepareStatement(connForExecSql);
* connForExecPstmt.setString(1, enterpriseCode);
* ResultSet connForExecRs = connForExecPstmt.executeQuery();
* while (connForExecRs.next()) {
* System.out.println(
* "EXECUTION CONNECTION USER ::: "
* + connForExecRs.getString(1));
* connForExec = connForExecRs.getString("schema_name");
* }
*/
connForExec = schemaName;
......@@ -2464,11 +2473,11 @@
? e.getMessage()
: e.toString();
System.out.println("Catch block for executeAndLog method for creating connection...." + error);
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error, "");
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error,
"");
}
int updCount = 0;
String error = null;
......@@ -2544,13 +2553,15 @@
String dropSynSql = "DROP SYNONYM " + dbRead + "." + objName;
System.out.println(
"Attempting to drop related synonym via Enterprise Config: " + dropSynSql);
"Attempting to drop related synonym via Enterprise Config: "
+ dropSynSql);
// Execute blindly. If it doesn't exist, we catch the exception.
stmt.execute(dropSynSql);
System.out.println("Synonym dropped successfully.");
} else {
System.out.println("Skipping synonym drop: DB_READ not found in Enterprise table.");
System.out.println(
"Skipping synonym drop: DB_READ not found in Enterprise table.");
}
}
} catch (SQLException synEx) {
......@@ -2629,6 +2640,31 @@
if (conn != null)
conn.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (connForSchema != null && !connForSchema.isClosed()) {
connForSchema.close();
connForSchema = null;
}
if (connForQueryExec != null && !connForQueryExec.isClosed()) {
connForQueryExec.close();
connForQueryExec = null;
}
if (conn != null && !conn.isClosed()) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private boolean isDdl(String sql) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment