Commit 9f499896 authored by Ajit Deshmukh's avatar Ajit Deshmukh

Rresolved the issue reported by the QC for duplicate records in SQL Log screen

parent f9a9cae0
...@@ -569,7 +569,6 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -569,7 +569,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
BaseLogger.log("1", null, null, BaseLogger.log("1", null, null,
"Before Savepoint"); "Before Savepoint");
String sanitizedEnterprise = mainEnterprise.replaceAll("[^a-zA-Z0-9_]", ""); String sanitizedEnterprise = mainEnterprise.replaceAll("[^a-zA-Z0-9_]", "");
BaseLogger.log("1", null, null, BaseLogger.log("1", null, null,
"Savepoint Name :: SP_" + sanitizedEnterprise); "Savepoint Name :: SP_" + sanitizedEnterprise);
...@@ -633,10 +632,15 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -633,10 +632,15 @@ public class ManageSqlConf extends ActionHandlerEJB {
ResultSet rsToFetchEntForP = null; ResultSet rsToFetchEntForP = null;
// Added by Gagan B. on 13-NOV-25 [make connection with Driver for ENTERPRISE] // Added by Gagan B. on 13-NOV-25 [make connection with Driver for ENTERPRISE]
// -- END // -- END
BaseLogger.log("1", null, null,
"enterpriser<><<> "+enterpriser);
String EnterPriseInFormat = getFormattedStringBuff(mainEnterprise); String EnterPriseInFormat = getFormattedStringBuff(mainEnterprise);
sql = "SELECT SCHEMA_NAME,ENTERPRISE FROM ENTERPRISE WHERE ENTERPRISE IN(" sql = "SELECT SCHEMA_NAME, ENTERPRISE " +
+ EnterPriseInFormat + ") "; "FROM ENTERPRISE " +
"WHERE ENTERPRISE = ?";
pstmt = entCon.prepareStatement(sql); pstmt = entCon.prepareStatement(sql);
pstmt.setString(1, enterpriser);
rsToFetchEntForP = pstmt.executeQuery(); rsToFetchEntForP = pstmt.executeQuery();
while (rsToFetchEntForP.next()) { while (rsToFetchEntForP.next()) {
// schemaName = checkNull( rs.getString("SCHEMA_NAME") ); // schemaName = checkNull( rs.getString("SCHEMA_NAME") );
...@@ -747,7 +751,8 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -747,7 +751,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
"P", "P",
false); false);
} }
} else if ("C".equalsIgnoreCase(execRights)) { }
else if ("C".equalsIgnoreCase(execRights)) {
// CLIENT DEV: DB_DEV is a schema name, not an enterprise code, // CLIENT DEV: DB_DEV is a schema name, not an enterprise code,
// so processSqlForEnterprise cannot look it up. Instead, apply // so processSqlForEnterprise cannot look it up. Instead, apply
// schema injection and call executeAndLog directly using the // schema injection and call executeAndLog directly using the
...@@ -1844,11 +1849,19 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -1844,11 +1849,19 @@ public class ManageSqlConf extends ActionHandlerEJB {
String chgTerm, String chgTerm,
String execRights) throws Exception { String execRights) throws Exception {
try {
try{ BaseLogger.log(
"3",
null,
null,
"processSqlForEnterprise START -> enterpriseCode="
+ enterpriseCode
+ ", tranId="
+ tranId
+ ", execRights="
+ execRights);
System.out.println("processSqlForEnterprise START :: " + enterpriseCode);
// Change by Gagan B. on 16-JAN-26 // Change by Gagan B. on 16-JAN-26
// --- FIX: Don't inject placeholders into PL/SQL Bodies --- // --- FIX: Don't inject placeholders into PL/SQL Bodies ---
String upperSql = checkNull(inputSql).trim().toUpperCase(); String upperSql = checkNull(inputSql).trim().toUpperCase();
...@@ -2014,13 +2027,12 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2014,13 +2027,12 @@ public class ManageSqlConf extends ActionHandlerEJB {
null, null,
"Pilot actual schema user : [" + schemaForPilot + "]"); "Pilot actual schema user : [" + schemaForPilot + "]");
if(connForPilotSchema!=null){ if (connForPilotSchema != null) {
connForPilotSchema.close(); connForPilotSchema.close();
connForPilotSchema = null; connForPilotSchema = null;
} }
} }
/* /*
* Fetch actual Main schema user * Fetch actual Main schema user
* Required for execRights = P and A * Required for execRights = P and A
...@@ -2030,7 +2042,8 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2030,7 +2042,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
ConnDriver connDriverForMainSchema = new ConnDriver(); ConnDriver connDriverForMainSchema = new ConnDriver();
Connection connForMainSchema = null; Connection connForMainSchema = null;
System.out.println("dbMain hashcode = " + dbMain.hashCode());
System.out.println("dbMain value = " + dbMain);
connForMainSchema = connDriverForMainSchema.getConnectDB(dbMain); connForMainSchema = connDriverForMainSchema.getConnectDB(dbMain);
String schemaForMainSql = "SELECT USER FROM DUAL"; String schemaForMainSql = "SELECT USER FROM DUAL";
...@@ -2085,7 +2098,6 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2085,7 +2098,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
*/ */
String grantSql = null; String grantSql = null;
// For Pilot transaction Create Table query grant rights of SELECT, INSERT, // For Pilot transaction Create Table query grant rights of SELECT, INSERT,
// UPDATE, DELETE // UPDATE, DELETE
if ("TABLE".equalsIgnoreCase(createObjectType)) { if ("TABLE".equalsIgnoreCase(createObjectType)) {
...@@ -2206,8 +2218,7 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2206,8 +2218,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
System.out.println("Execution completed successfully."); System.out.println("Execution completed successfully.");
} } catch (Exception e) {
catch(Exception e){
String error = (e.getMessage() != null) String error = (e.getMessage() != null)
? e.getMessage() ? e.getMessage()
...@@ -2259,7 +2270,8 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2259,7 +2270,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
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 return; // Stop execution if connection fails
} }
// Changes by Ajit D. on 08-JUNE-26 for the query execution schema name fetched it // Changes by Ajit D. on 08-JUNE-26 for the query execution schema name fetched
// it
// from USERS // from USERS
BaseLogger.log("3", null, null, "For schemaName: [" + schemaName + "]"); BaseLogger.log("3", null, null, "For schemaName: [" + schemaName + "]");
...@@ -2324,7 +2336,7 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2324,7 +2336,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
+ schemaForPlaceHolder + "]"); + schemaForPlaceHolder + "]");
} }
if(schemaName.equalsIgnoreCase("APPVIS")){ if (schemaName.equalsIgnoreCase("APPVIS")) {
BaseLogger.log( BaseLogger.log(
"3", "3",
null, null,
...@@ -2361,8 +2373,6 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2361,8 +2373,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
System.out.println("execSchema:: " + execSchema); System.out.println("execSchema:: " + execSchema);
System.out.println("enterpriseCode:: " + enterpriseCode); System.out.println("enterpriseCode:: " + enterpriseCode);
// 1. Get the Connection String for the Main Execution // 1. Get the Connection String for the Main Execution
String connForExecSql = "select schema_name from enterprise where enterprise = ?"; String connForExecSql = "select schema_name from enterprise where enterprise = ?";
PreparedStatement connForExecPstmt = conn.prepareStatement(connForExecSql); PreparedStatement connForExecPstmt = conn.prepareStatement(connForExecSql);
...@@ -2377,8 +2387,18 @@ public class ManageSqlConf extends ActionHandlerEJB { ...@@ -2377,8 +2387,18 @@ public class ManageSqlConf extends ActionHandlerEJB {
} }
System.out.println("connForExec:: " + connForExec); System.out.println("connForExec:: " + connForExec);
try {
// Connect to the specific schema // Connect to the specific schema
connForQueryExec = connDriver.getConnectDB(connForExec); connForQueryExec = connDriver.getConnectDB(connForExec);
} catch (Exception e) {
String error = (e.getMessage() != null)
? 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, "");
}
int updCount = 0; int updCount = 0;
String error = null; String error = null;
......
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