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 {
BaseLogger.log("1", null, null,
"Before Savepoint");
String sanitizedEnterprise = mainEnterprise.replaceAll("[^a-zA-Z0-9_]", "");
BaseLogger.log("1", null, null,
"Savepoint Name :: SP_" + sanitizedEnterprise);
......@@ -626,17 +625,22 @@ public class ManageSqlConf extends ActionHandlerEJB {
con.setAutoCommit(false);
// TO fetch the schemaName and enterprise for live[START]
ArrayList<String> enterpriseArrayListForP = new ArrayList<>();
ArrayList<String> enterpriseArrayListForP = new ArrayList<>();
Connection entCon = null;
ConnDriver connDriver = new ConnDriver();
entCon = connDriver.getConnectDB("Driver");
ResultSet rsToFetchEntForP = null;
// Added by Gagan B. on 13-NOV-25 [make connection with Driver for ENTERPRISE]
// -- END
BaseLogger.log("1", null, null,
"enterpriser<><<> "+enterpriser);
String EnterPriseInFormat = getFormattedStringBuff(mainEnterprise);
sql = "SELECT SCHEMA_NAME,ENTERPRISE FROM ENTERPRISE WHERE ENTERPRISE IN("
+ EnterPriseInFormat + ") ";
sql = "SELECT SCHEMA_NAME, ENTERPRISE " +
"FROM ENTERPRISE " +
"WHERE ENTERPRISE = ?";
pstmt = entCon.prepareStatement(sql);
pstmt.setString(1, enterpriser);
rsToFetchEntForP = pstmt.executeQuery();
while (rsToFetchEntForP.next()) {
// schemaName = checkNull( rs.getString("SCHEMA_NAME") );
......@@ -747,7 +751,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
"P",
false);
}
} else if ("C".equalsIgnoreCase(execRights)) {
}
else if ("C".equalsIgnoreCase(execRights)) {
// CLIENT DEV: DB_DEV is a schema name, not an enterprise code,
// so processSqlForEnterprise cannot look it up. Instead, apply
// schema injection and call executeAndLog directly using the
......@@ -1844,321 +1849,328 @@ public class ManageSqlConf extends ActionHandlerEJB {
String chgTerm,
String execRights) throws Exception {
try {
try{
// Change by Gagan B. on 16-JAN-26
// --- FIX: Don't inject placeholders into PL/SQL Bodies ---
String upperSql = checkNull(inputSql).trim().toUpperCase();
boolean isPlSqlBody = upperSql.startsWith("CREATE OR REPLACE FUNCTION")
|| upperSql.startsWith("CREATE FUNCTION")
|| upperSql.startsWith("CREATE OR REPLACE PROCEDURE")
|| upperSql.startsWith("CREATE PROCEDURE")
|| upperSql.startsWith("CREATE OR REPLACE PACKAGE")
|| upperSql.startsWith("CREATE PACKAGE")
|| upperSql.startsWith("CREATE OR REPLACE TYPE")
|| upperSql.startsWith("CREATE TYPE")
|| upperSql.startsWith("CREATE OR REPLACE TRIGGER")
|| upperSql.startsWith("CREATE TRIGGER")
|| upperSql.contains("NONEDITIONABLE"); // Catch the specific case
if (!isPlSqlBody) {
inputSql = injectSchemaPlaceholderSafe(inputSql);
}
System.out.println("inputSql gsb:::::>>>><<<<< " + inputSql);
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
// --- FIX: Don't inject placeholders into PL/SQL Bodies ---
String upperSql = checkNull(inputSql).trim().toUpperCase();
boolean isPlSqlBody = upperSql.startsWith("CREATE OR REPLACE FUNCTION")
|| upperSql.startsWith("CREATE FUNCTION")
|| upperSql.startsWith("CREATE OR REPLACE PROCEDURE")
|| upperSql.startsWith("CREATE PROCEDURE")
|| upperSql.startsWith("CREATE OR REPLACE PACKAGE")
|| upperSql.startsWith("CREATE PACKAGE")
|| upperSql.startsWith("CREATE OR REPLACE TYPE")
|| upperSql.startsWith("CREATE TYPE")
|| upperSql.startsWith("CREATE OR REPLACE TRIGGER")
|| upperSql.startsWith("CREATE TRIGGER")
|| upperSql.contains("NONEDITIONABLE"); // Catch the specific case
if (!isPlSqlBody) {
inputSql = injectSchemaPlaceholderSafe(inputSql);
}
System.out.println("inputSql gsb:::::>>>><<<<< " + inputSql);
/*
* -------------------------------
* Fetch schemas
* -------------------------------
*/
String query = "SELECT DB_DEV, DB_MAIN, DB_READ, DB_PILOT " +
"FROM enterprise WHERE enterprise = ?";
/*
* -------------------------------
* Fetch schemas
* -------------------------------
*/
String query = "SELECT DB_DEV, DB_MAIN, DB_READ, DB_PILOT " +
"FROM enterprise WHERE enterprise = ?";
String dbMain, dbRead, dbPilot;
String dbMain, dbRead, dbPilot;
try (PreparedStatement ps = conn.prepareStatement(query)) {
ps.setString(1, enterpriseCode);
try (ResultSet rs = ps.executeQuery()) {
if (!rs.next()) {
throw new Exception("No enterprise found for: " + enterpriseCode);
try (PreparedStatement ps = conn.prepareStatement(query)) {
ps.setString(1, enterpriseCode);
try (ResultSet rs = ps.executeQuery()) {
if (!rs.next()) {
throw new Exception("No enterprise found for: " + enterpriseCode);
}
dbMain = rs.getString("DB_MAIN");
dbRead = rs.getString("DB_READ");
dbPilot = rs.getString("DB_PILOT");
}
dbMain = rs.getString("DB_MAIN");
dbRead = rs.getString("DB_READ");
dbPilot = rs.getString("DB_PILOT");
}
}
BaseLogger.log("3", null, null, "dbMain:: " + dbMain + " dbRead:: " + dbRead + " dbPilot:: " + dbPilot);
/*
* -------------------------------
* Get CURRENT_USER
* -------------------------------
*/
String currentUser;
try (PreparedStatement ps = conn.prepareStatement("SELECT USER FROM DUAL");
ResultSet rs = ps.executeQuery()) {
rs.next();
currentUser = rs.getString(1);
}
System.out.println("CURRENT_USER :::: " + currentUser);
/*
* -------------------------------
* Schema execution rules
* -------------------------------
*/
Map<String, String> schemaRules = new LinkedHashMap<>();
schemaRules.put(dbMain, "ALL");
// schemaRules.put(dbDev, "ALL");
schemaRules.put(dbRead, "SYN");
// schemaRules.put(dbPilot, "SYN");
System.out.println("execRights ::: " + execRights);
if ("P".equalsIgnoreCase(execRights)
&& dbPilot != null
&& !dbPilot.trim().isEmpty()) {
schemaRules.put(dbPilot, "SYN");
}
BaseLogger.log("3", null, null, "dbMain:: " + dbMain + " dbRead:: " + dbRead + " dbPilot:: " + dbPilot);
/*
* -------------------------------
* Get CURRENT_USER
* -------------------------------
*/
String currentUser;
try (PreparedStatement ps = conn.prepareStatement("SELECT USER FROM DUAL");
ResultSet rs = ps.executeQuery()) {
String createObjectType = getCreateObjectType(inputSql);
boolean isCreateObject = createObjectType != null;
String objectName = isCreateObject ? extractObjectName(inputSql) : null;
rs.next();
currentUser = rs.getString(1);
}
System.out.println("objectName ::: " + objectName);
System.out.println("createObjectType ::: " + createObjectType);
System.out.println("schemaRules:: " + schemaRules);
/*
* -------------------------------
* Execute per schema
* -------------------------------
*/
for (Map.Entry<String, String> entry : schemaRules.entrySet()) {
System.out.println("CURRENT_USER :::: " + currentUser);
String schemaName = entry.getKey();
String rule = entry.getValue();
System.out.println("schemaName ::: " + schemaName);
System.out.println("dbPilot ::: " + dbPilot);
System.out.println("rule ::: " + rule);
/*
* -------------------------------
* Schema execution rules
* -------------------------------
*/
Map<String, String> schemaRules = new LinkedHashMap<>();
schemaRules.put(dbMain, "ALL");
// schemaRules.put(dbDev, "ALL");
schemaRules.put(dbRead, "SYN");
// schemaRules.put(dbPilot, "SYN");
System.out.println("execRights ::: " + execRights);
if ("P".equalsIgnoreCase(execRights)
&& dbPilot != null
&& !dbPilot.trim().isEmpty()) {
schemaRules.put(dbPilot, "SYN");
}
if (schemaName == null || schemaName.trim().isEmpty())
continue;
String createObjectType = getCreateObjectType(inputSql);
boolean isCreateObject = createObjectType != null;
String objectName = isCreateObject ? extractObjectName(inputSql) : null;
System.out.println("objectName ::: " + objectName);
System.out.println("createObjectType ::: " + createObjectType);
System.out.println("schemaRules:: " + schemaRules);
/*
* =====================================
* CREATE / DDL FLOW
* =====================================
* -------------------------------
* Execute per schema
* -------------------------------
*/
if (isCreateObject) {
if ("ALL".equals(rule)) {
executeAndLog(
schemaName,
inputSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
true);
} else if ("SYN".equals(rule)) {
// // Skip synonym & grant if CURRENT_USER is owner
// if (currentUser.equalsIgnoreCase(dbMain)) {
// System.out.println(
// "Skipping SYN. CURRENT_USER is DB_MAIN."
// );
// continue;
// }
/*
* -----------------------------
* Create synonym in CURRENT_USER
* -----------------------------
*/
for (Map.Entry<String, String> entry : schemaRules.entrySet()) {
System.out.println("dbMain ::: " + dbMain);
System.out.println("schemaName ::: " + schemaName);
String schemaName = entry.getKey();
String rule = entry.getValue();
System.out.println("schemaName ::: " + schemaName);
System.out.println("dbPilot ::: " + dbPilot);
System.out.println("rule ::: " + rule);
String schemaForPilot = schemaName;
String schemaForMain = dbMain;
if (schemaName == null || schemaName.trim().isEmpty())
continue;
if ("P".equalsIgnoreCase(execRights) && schemaName.equalsIgnoreCase(dbPilot)) {
/*
* =====================================
* CREATE / DDL FLOW
* =====================================
*/
if (isCreateObject) {
ConnDriver connDriverForPilotSchema = new ConnDriver();
Connection connForPilotSchema = null;
if ("ALL".equals(rule)) {
connForPilotSchema = connDriverForPilotSchema.getConnectDB(schemaName);
executeAndLog(
schemaName,
inputSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
true);
String schemaForPilotSql = "SELECT USER FROM DUAL";
} else if ("SYN".equals(rule)) {
PreparedStatement schemaForPilotPs = connForPilotSchema.prepareStatement(schemaForPilotSql);
// // Skip synonym & grant if CURRENT_USER is owner
// if (currentUser.equalsIgnoreCase(dbMain)) {
// System.out.println(
// "Skipping SYN. CURRENT_USER is DB_MAIN."
// );
// continue;
// }
ResultSet schemaForPilotRs = schemaForPilotPs.executeQuery();
/*
* -----------------------------
* Create synonym in CURRENT_USER
* -----------------------------
*/
if (schemaForPilotRs.next()) {
schemaForPilot = checkNull(schemaForPilotRs.getString(1));
}
System.out.println("dbMain ::: " + dbMain);
System.out.println("schemaName ::: " + schemaName);
BaseLogger.log(
"3",
null,
null,
"Pilot actual schema user : [" + schemaForPilot + "]");
String schemaForPilot = schemaName;
String schemaForMain = dbMain;
if(connForPilotSchema!=null){
connForPilotSchema.close();
connForPilotSchema = null;
}
}
if ("P".equalsIgnoreCase(execRights) && schemaName.equalsIgnoreCase(dbPilot)) {
ConnDriver connDriverForPilotSchema = new ConnDriver();
Connection connForPilotSchema = null;
/*
* Fetch actual Main schema user
* Required for execRights = P and A
*/
if ("P".equalsIgnoreCase(execRights)
|| "A".equalsIgnoreCase(execRights)) {
connForPilotSchema = connDriverForPilotSchema.getConnectDB(schemaName);
ConnDriver connDriverForMainSchema = new ConnDriver();
Connection connForMainSchema = null;
String schemaForPilotSql = "SELECT USER FROM DUAL";
connForMainSchema = connDriverForMainSchema.getConnectDB(dbMain);
PreparedStatement schemaForPilotPs = connForPilotSchema.prepareStatement(schemaForPilotSql);
String schemaForMainSql = "SELECT USER FROM DUAL";
ResultSet schemaForPilotRs = schemaForPilotPs.executeQuery();
PreparedStatement schemaForMainPs = connForMainSchema.prepareStatement(schemaForMainSql);
if (schemaForPilotRs.next()) {
schemaForPilot = checkNull(schemaForPilotRs.getString(1));
}
ResultSet schemaForMainRs = schemaForMainPs.executeQuery();
BaseLogger.log(
"3",
null,
null,
"Pilot actual schema user : [" + schemaForPilot + "]");
if (schemaForMainRs.next()) {
schemaForMain = checkNull(schemaForMainRs.getString(1));
if (connForPilotSchema != null) {
connForPilotSchema.close();
connForPilotSchema = null;
}
}
BaseLogger.log(
"3",
null,
null,
"Main actual schema user ::::::::: [" + schemaForMain + "]");
/*
* Fetch actual Main schema user
* Required for execRights = P and A
*/
if ("P".equalsIgnoreCase(execRights)
|| "A".equalsIgnoreCase(execRights)) {
if (connForMainSchema != null) {
connForMainSchema.close();
connForMainSchema = null;
}
}
ConnDriver connDriverForMainSchema = new ConnDriver();
Connection connForMainSchema = null;
System.out.println("dbMain hashcode = " + dbMain.hashCode());
System.out.println("dbMain value = " + dbMain);
connForMainSchema = connDriverForMainSchema.getConnectDB(dbMain);
String targetSchema = schemaName;
String schemaForMainSql = "SELECT USER FROM DUAL";
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
targetSchema = schemaForPilot;
}
PreparedStatement schemaForMainPs = connForMainSchema.prepareStatement(schemaForMainSql);
String synonymSql = "CREATE SYNONYM " + targetSchema + "." + objectName +
" FOR " + schemaForMain + "." + objectName;
executeAndLog(
schemaName,
synonymSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
false);
ResultSet schemaForMainRs = schemaForMainPs.executeQuery();
/*
* -----------------------------
* Grant based on object type
* -----------------------------
*/
String grantSql = null;
if (schemaForMainRs.next()) {
schemaForMain = checkNull(schemaForMainRs.getString(1));
}
// For Pilot transaction Create Table query grant rights of SELECT, INSERT,
// UPDATE, DELETE
if ("TABLE".equalsIgnoreCase(createObjectType)) {
BaseLogger.log(
"3",
null,
null,
"Main actual schema user ::::::::: [" + schemaForMain + "]");
if (connForMainSchema != null) {
connForMainSchema.close();
connForMainSchema = null;
}
}
targetSchema = schemaName;
String targetSchema = schemaName;
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
targetSchema = schemaForPilot;
}
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
String synonymSql = "CREATE SYNONYM " + targetSchema + "." + objectName +
" FOR " + schemaForMain + "." + objectName;
grantSql = "GRANT SELECT, INSERT, UPDATE, DELETE ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
executeAndLog(
schemaName,
synonymSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
false);
/*
* -----------------------------
* Grant based on object type
* -----------------------------
*/
String grantSql = null;
// For Pilot transaction Create Table query grant rights of SELECT, INSERT,
// UPDATE, DELETE
if ("TABLE".equalsIgnoreCase(createObjectType)) {
targetSchema = schemaName;
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
targetSchema = schemaForPilot;
}
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
} else {
grantSql = "GRANT SELECT, INSERT, UPDATE, DELETE ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
} else {
grantSql = "GRANT SELECT ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
}
} else if ("VIEW".equalsIgnoreCase(createObjectType)
|| "SEQUENCE".equalsIgnoreCase(createObjectType)) {
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
grantSql = "GRANT SELECT ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
}
} else if ("VIEW".equalsIgnoreCase(createObjectType)
|| "SEQUENCE".equalsIgnoreCase(createObjectType)) {
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
} else if ("PROCEDURE".equalsIgnoreCase(createObjectType)
|| "FUNCTION".equalsIgnoreCase(createObjectType)
|| "PACKAGE".equalsIgnoreCase(createObjectType)
|| "TYPE".equalsIgnoreCase(createObjectType)) {
grantSql = "GRANT SELECT ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
} else if ("PROCEDURE".equalsIgnoreCase(createObjectType)
|| "FUNCTION".equalsIgnoreCase(createObjectType)
|| "PACKAGE".equalsIgnoreCase(createObjectType)
|| "TYPE".equalsIgnoreCase(createObjectType)) {
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
grantSql = "GRANT EXECUTE ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
grantSql = "GRANT EXECUTE ON "
+ schemaForMain + "." + objectName
+ " TO " + targetSchema;
}
BaseLogger.log(
"3",
null,
null,
"grantSql [[" + grantSql + "]");
}
BaseLogger.log(
"3",
null,
null,
"grantSql [[" + grantSql + "]");
BaseLogger.log(
"3",
null,
null,
"schemaName [" + schemaName + "]");
BaseLogger.log(
"3",
null,
null,
"dbMain [" + dbMain + "]");
BaseLogger.log(
"3",
null,
null,
"schemaName [" + schemaName + "]");
BaseLogger.log(
"3",
null,
null,
"dbMain [" + dbMain + "]");
BaseLogger.log(
"3",
null,
null,
"dbRead [[" + dbRead + "]");
BaseLogger.log(
"3",
null,
null,
"dbRead [[" + dbRead + "]");
if (grantSql != null) {
executeAndLog(
......@@ -2174,47 +2186,46 @@ public class ManageSqlConf extends ActionHandlerEJB {
"",
false);
}
}
continue; // Skip DML flow
}
continue; // Skip DML flow
}
/*
* =====================================
* INSERT / UPDATE / DELETE FLOW
* =====================================
*/
if ("SYN".equals(rule)) {
System.out.println(
"Skipping DML for SYN-only schema: " + schemaName);
continue;
}
/*
* =====================================
* INSERT / UPDATE / DELETE FLOW
* =====================================
*/
if ("SYN".equals(rule)) {
System.out.println(
"Skipping DML for SYN-only schema: " + schemaName);
continue;
executeAndLog(
schemaName,
inputSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
false);
}
executeAndLog(
schemaName,
inputSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
false);
}
System.out.println("Execution completed successfully.");
System.out.println("Execution completed successfully.");
} catch (Exception e) {
}
catch(Exception e){
String error = (e.getMessage() != null)
? e.getMessage()
: e.toString();
System.out.println("Catch block for processSqlForEnterprise method...." + error);
? e.getMessage()
: e.toString();
System.out.println("Catch block for processSqlForEnterprise method...." + error);
logSqlExecution(tranId, enterpriseCode, "0", requestID, inputSql, 0, "E", userId, chgTerm, error, "");
}
}
}
// Created a method to execute the SQL in the schemas stored in the Enterprise
......@@ -2259,85 +2270,86 @@ public class ManageSqlConf extends ActionHandlerEJB {
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 it
// Changes by Ajit D. on 08-JUNE-26 for the query execution schema name fetched
// it
// from USERS
BaseLogger.log("3", null, null, "For schemaName: [" + schemaName + "]");
BaseLogger.log("3", null, null, "executeAndLog inputSql: [" + inputSql + "]");
String dbReadForCheck = "";
BaseLogger.log("3", null, null, "For schemaName: [" + schemaName + "]");
BaseLogger.log("3", null, null, "executeAndLog inputSql: [" + inputSql + "]");
String dbReadForCheck = "";
/*
* Fetch DB_READ for the current enterprise
*/
String dbReadSql = "SELECT DB_READ FROM ENTERPRISE WHERE ENTERPRISE = ?";
/*
* Fetch DB_READ for the current enterprise
*/
String dbReadSql = "SELECT DB_READ FROM ENTERPRISE WHERE ENTERPRISE = ?";
PreparedStatement dbReadPs = conn.prepareStatement(dbReadSql);
PreparedStatement dbReadPs = conn.prepareStatement(dbReadSql);
dbReadPs.setString(1, enterpriseCode);
dbReadPs.setString(1, enterpriseCode);
ResultSet dbReadRs = dbReadPs.executeQuery();
ResultSet dbReadRs = dbReadPs.executeQuery();
if (dbReadRs.next()) {
dbReadForCheck = checkNull(dbReadRs.getString("DB_READ"));
}
if (dbReadRs.next()) {
dbReadForCheck = checkNull(dbReadRs.getString("DB_READ"));
}
BaseLogger.log(
"3",
null,
null,
"DB_READ fetched from enterprise : [" + dbReadForCheck + "]");
/*
* For DB_READ use configured value directly.
* For all other schemas fetch actual Oracle USER.
*/
if (schemaName.equalsIgnoreCase(dbReadForCheck)) {
schemaForPlaceHolder = schemaName;
BaseLogger.log(
"3",
null,
null,
"DB_READ fetched from enterprise : [" + dbReadForCheck + "]");
/*
* For DB_READ use configured value directly.
* For all other schemas fetch actual Oracle USER.
*/
if (schemaName.equalsIgnoreCase(dbReadForCheck)) {
schemaForPlaceHolder = schemaName;
BaseLogger.log(
"3",
null,
null,
"Using DB_READ directly as schema : ["
+ schemaForPlaceHolder + "]");
} else {
"Using DB_READ directly as schema : ["
+ schemaForPlaceHolder + "]");
connForSchema = connDriverForSchema.getConnectDB(schemaName);
} else {
String schemaSql = "SELECT USER FROM DUAL";
connForSchema = connDriverForSchema.getConnectDB(schemaName);
PreparedStatement schemaForPs = connForSchema.prepareStatement(schemaSql);
String schemaSql = "SELECT USER FROM DUAL";
ResultSet schemaForRs = schemaForPs.executeQuery();
PreparedStatement schemaForPs = connForSchema.prepareStatement(schemaSql);
if (schemaForRs.next()) {
schemaForPlaceHolder = checkNull(schemaForRs.getString(1));
}
ResultSet schemaForRs = schemaForPs.executeQuery();
BaseLogger.log(
"3",
null,
null,
"Actual Oracle USER : ["
+ schemaForPlaceHolder + "]");
if (schemaForRs.next()) {
schemaForPlaceHolder = checkNull(schemaForRs.getString(1));
}
if(schemaName.equalsIgnoreCase("APPVIS")){
BaseLogger.log(
"3",
null,
null,
"For std database");
schemaForPlaceHolder = "APPVIS";
}
BaseLogger.log(
"3",
null,
null,
"schemaForPlaceHolder : ["
"Actual Oracle USER : ["
+ schemaForPlaceHolder + "]");
}
if (schemaName.equalsIgnoreCase("APPVIS")) {
BaseLogger.log(
"3",
null,
null,
"For std database");
schemaForPlaceHolder = "APPVIS";
}
BaseLogger.log(
"3",
null,
null,
"schemaForPlaceHolder : ["
+ schemaForPlaceHolder + "]");
String finalSql = applySchema(inputSql, schemaForPlaceHolder);
......@@ -2361,8 +2373,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
System.out.println("execSchema:: " + execSchema);
System.out.println("enterpriseCode:: " + enterpriseCode);
// 1. Get the Connection String for the Main Execution
String connForExecSql = "select schema_name from enterprise where enterprise = ?";
PreparedStatement connForExecPstmt = conn.prepareStatement(connForExecSql);
......@@ -2377,8 +2387,18 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
System.out.println("connForExec:: " + connForExec);
// Connect to the specific schema
connForQueryExec = connDriver.getConnectDB(connForExec);
try {
// Connect to the specific schema
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;
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