Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
c88c0ade
Commit
c88c0ade
authored
Jun 12, 2026
by
Ajit Deshmukh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handled the special characters case while creating the SavePoint in the ManageSqlConf
parent
2d1a5321
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
159 additions
and
83 deletions
+159
-83
Ajit/Manage SQL Changes APR-26/Java Components/ManageSqlConf.java
...age SQL Changes APR-26/Java Components/ManageSqlConf.java
+159
-83
No files found.
Ajit/Manage SQL Changes APR-26/Java Components/ManageSqlConf.java
View file @
c88c0ade
...
...
@@ -96,10 +96,10 @@ public class ManageSqlConf extends ActionHandlerEJB {
pstmt = null;
}
if
(
execRights
.
trim
().
length
()==
0
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Blank Execution Rights"
);
if
(execRights.trim().length() == 0)
{
BaseLogger.log("3", null, null, "Blank Execution Rights");
errString = itmdbAccessLocal.getErrorString("confirmed", "MSQLBER", "", "", con);
return
errString
;
return errString;
}
if (confirmed.trim().equalsIgnoreCase("Y")) {
BaseLogger.log("3", null, null, "Transaction is already confirmed Tran ID:: " + tranId);
...
...
@@ -209,15 +209,12 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
}
// Added for CLIENT DEV: C transaction can only be confirmed after P (PILOT) is
// confirmed
if ("C".equalsIgnoreCase(execRights)) {
System.out
.println("This transaction has exec_rights = 'C', checking for dependent 'C' confirmation...");
String cCheckSql = "SELECT CONFIRMED FROM SQL_CHANGES WHERE EXEC_RIGHTS = 'P' AND tran_id__ref = ?";
pstmt = con.prepareStatement(cCheckSql);
pstmt.setString(1, tranIdRef);
...
...
@@ -248,7 +245,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
}
// Changes Start -- 13 Nov AJIT (Condition for exec_rights = 'A')
if ("A".equalsIgnoreCase(execRights)) {
System.out.println(
...
...
@@ -496,15 +492,14 @@ public class ManageSqlConf extends ActionHandlerEJB {
String dbMainForPilot = "";
String dbClientDev = "";
BaseLogger.log("3", null, null, "execRights [" + execRights + "]");
if ("Q".equalsIgnoreCase(execRights)) {
QcDevEnterprise = "APPVISQC";
BaseLogger.log(
"1"
,
null
,
null
,
"Executing for QC "
);
"1",
null,
null,
"Executing for QC ");
// D/Q: enterprise code matches ENTERPRISE table directly
processSqlForEnterprise(
con,
...
...
@@ -515,8 +510,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
requestID,
userId,
chgTerm,
"Q"
);
"Q");
}
// For PILOT, look up DB_PILOT from enterprise table using the main
...
...
@@ -571,8 +565,17 @@ public class ManageSqlConf extends ActionHandlerEJB {
try {
// ENTERPRISE-LEVEL SAVEPOINT
entSavepoint
=
con
.
setSavepoint
(
"SP_"
+
QcDevEnterprise
);
BaseLogger.log("1", null, null,
"Before Savepoint");
String sanitizedEnterprise = mainEnterprise.replaceAll("[^a-zA-Z0-9_]", "");
BaseLogger.log("1", null, null,
"Savepoint Name :: SP_" + sanitizedEnterprise);
entSavepoint = con.setSavepoint("SP_" + sanitizedEnterprise);
BaseLogger.log("1", null, null,
"After Savepoint");
if ("P".equalsIgnoreCase(execRights)) {
String pilotInputSql = oracleStatment;
...
...
@@ -594,7 +597,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
pilotInputSql = injectSchemaPlaceholderSafe(pilotInputSql);
}
//Made changes by Ajit D. on 10-June for No DDL should get executed in PILOT schema & READ schema
// Made changes by Ajit D. on 10-June for No DDL should get executed in PILOT
// schema & READ schema
// and Only DML will get executed in PILOT schema
// DDL check
boolean isPilotDDL = (upperSqlP.startsWith("CREATE")
...
...
@@ -621,7 +625,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
// VERY IMPORTANT
con.setAutoCommit(false);
// TO fetch the schemaName and enterprise for live[START]
Connection entCon = null;
...
...
@@ -640,7 +643,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
// enterpriseSQL = checkNull( rs.getString("ENTERPRISE") );
// schemaListMap.put(schemaName,enterpriseSQL);
enterpriseArrayList
.
add
(
checkNull
(
rsToFetchEntForP
.
getString
(
"ENTERPRISE"
)));
enterpriseArrayList
.add(checkNull(rsToFetchEntForP.getString("ENTERPRISE")));
}
if (pstmt != null) {
pstmt.close();
...
...
@@ -661,8 +665,6 @@ public class ManageSqlConf extends ActionHandlerEJB {
// TO fetch the enterprise for live[START]
BaseLogger.log("1", null, null,
"enterpriseArrayList :: " + enterpriseArrayList);
...
...
@@ -696,7 +698,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
try {
// ENTERPRISE-LEVEL SAVEPOINT
entSavepointForPilot
=
con
.
setSavepoint
(
"SP_"
+
ent
);
String sanitizedEnt = ent.replaceAll("[^a-zA-Z0-9_]", "");
entSavepointForPilot = con.setSavepoint("SP_" + sanitizedEnt);
processSqlForEnterprise(
con,
...
...
@@ -707,8 +710,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
requestID,
userId,
chgTerm,
"P"
);
"P");
// commit enterprise success
con.commit();
...
...
@@ -801,7 +803,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
}
} else {
}
}
if ("A".equalsIgnoreCase(execRights)) {
...
...
@@ -815,7 +817,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
// VERY IMPORTANT
con.setAutoCommit(false);
BaseLogger
.
log
(
"1"
,
null
,
null
,
"enterpriseArrayList :: "
+
enterpriseArrayList
);
BaseLogger.log("1", null, null, "enterpriseArrayList :: " + enterpriseArrayList
);
String[] enterpriseArr = null;
enterpriseArr = enterpriseArrayList.toArray(new String[0]);
...
...
@@ -832,9 +834,9 @@ public class ManageSqlConf extends ActionHandlerEJB {
* enterpriseArr = enterpriseArrayList.toArray(new String[0]);
* }
*/
BaseLogger
.
log
(
"1"
,
null
,
null
,
"enterpriseArr :: "
+
Arrays
.
toString
(
enterpriseArr
)
);
BaseLogger.log("1", null, null, "enterpriseArr :: " + Arrays.toString(enterpriseArr)
);
for (String enterpriseForExec : enterpriseArr) {
BaseLogger
.
log
(
"1"
,
null
,
null
,
"enterpriseForExec :: "
+
enterpriseForExec
);
BaseLogger.log("1", null, null, "enterpriseForExec ::: " + enterpriseForExec
);
String ent = enterpriseForExec.trim();
if (ent.isEmpty()) {
...
...
@@ -845,7 +847,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
try {
// ENTERPRISE-LEVEL SAVEPOINT
entSavepoint
=
con
.
setSavepoint
(
"SP_"
+
ent
);
String sanitizedEnt = ent.replaceAll("[^a-zA-Z0-9_]", "");
entSavepoint = con.setSavepoint("SP_" + sanitizedEnt);
processSqlForEnterprise(
con,
...
...
@@ -856,8 +859,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
requestID,
userId,
chgTerm,
"A"
);
"A");
// commit enterprise success
con.commit();
...
...
@@ -1401,15 +1403,15 @@ public class ManageSqlConf extends ActionHandlerEJB {
// Added condition if profileId is not MSADMIN return a validation
if (profileId != null) {
String
[]
profileIds
=
profileId
.
split
(
","
);
String[] profileIds = profileId.split(",");
for
(
String
id
:
profileIds
)
{
if
(
"MSADMIN"
.
equalsIgnoreCase
(
id
.
trim
()))
{
isMSADMIN
=
true
;
break
;
}
}
for (String id : profileIds) {
if ("MSADMIN".equalsIgnoreCase(id.trim())) {
isMSADMIN = true;
break;
}
}
}
if (!isMSADMIN) {
BaseLogger.log("3", getUserInfo(), null, "Only Admin can close this transaction.");
return itmdbAccessLocal.getErrorString("", "MSQLCNA", "", "", con);
...
...
@@ -1840,7 +1842,12 @@ public class ManageSqlConf extends ActionHandlerEJB {
String requestID,
String userId,
String chgTerm,
String
execRights
)
throws
Exception
{
String execRights) throws Exception {
try{
// Change by Gagan B. on 16-JAN-26
// --- FIX: Don't inject placeholders into PL/SQL Bodies ---
...
...
@@ -1870,7 +1877,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
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);
...
...
@@ -1883,7 +1890,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
dbPilot = rs.getString("DB_PILOT");
}
}
BaseLogger
.
log
(
"3"
,
null
,
null
,
"dbMain:: "
+
dbMain
+
" dbRead:: "
+
dbRead
+
" dbPilot:: "
+
dbPilot
);
BaseLogger.log("3", null, null, "dbMain:: " + dbMain
+ " dbRead:: " + dbRead + " dbPilot:: " +
dbPilot);
/*
* -------------------------------
* Get CURRENT_USER
...
...
@@ -1906,9 +1913,9 @@ public class ManageSqlConf extends ActionHandlerEJB {
*/
Map<String, String> schemaRules = new LinkedHashMap<>();
schemaRules.put(dbMain, "ALL");
//schemaRules.put(dbDev, "ALL");
//
schemaRules.put(dbDev, "ALL");
schemaRules.put(dbRead, "SYN");
//schemaRules.put(dbPilot, "SYN");
//
schemaRules.put(dbPilot, "SYN");
System.out.println("execRights ::: " + execRights);
if ("P".equalsIgnoreCase(execRights)
&& dbPilot != null
...
...
@@ -1923,7 +1930,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
System.out.println("objectName ::: " + objectName);
System.out.println("createObjectType ::: " + createObjectType);
System
.
out
.
println
(
"schemaRules:: "
+
schemaRules
);
System.out.println("schemaRules:: " +
schemaRules);
/*
* -------------------------------
* Execute per schema
...
...
@@ -1933,8 +1940,9 @@ public class ManageSqlConf extends ActionHandlerEJB {
String schemaName = entry.getKey();
String rule = entry.getValue();
System
.
out
.
println
(
"schemaName ::: "
+
schemaName
);
System
.
out
.
println
(
"rule ::: "
+
rule
);
System.out.println("schemaName ::: " + schemaName);
System.out.println("dbPilot ::: " + dbPilot);
System.out.println("rule ::: " + rule);
if (schemaName == null || schemaName.trim().isEmpty())
continue;
...
...
@@ -1976,7 +1984,43 @@ public class ManageSqlConf extends ActionHandlerEJB {
* Create synonym in CURRENT_USER
* -----------------------------
*/
String
synonymSql
=
"CREATE SYNONYM "
+
schemaName
+
"."
+
objectName
+
String schemaForPilot = schemaName;
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
ConnDriver connDriverForPilotSchema = new ConnDriver();
Connection connForPilotSchema = null;
connForPilotSchema = connDriverForPilotSchema.getConnectDB(schemaName);
String schemaForPilotSql = "SELECT USER FROM DUAL";
PreparedStatement schemaForPilotPs = connForPilotSchema.prepareStatement(schemaForPilotSql);
ResultSet schemaForPilotRs = schemaForPilotPs.executeQuery();
if (schemaForPilotRs.next()) {
schemaForPilot = checkNull(schemaForPilotRs.getString(1));
}
BaseLogger.log(
"3",
null,
null,
"Pilot actual schema user : [" + schemaForPilot + "]");
}
String targetSchema = schemaName;
if ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot)) {
targetSchema = schemaForPilot;
}
String synonymSql = "CREATE SYNONYM " + targetSchema + "." + objectName +
" FOR " + dbMain + "." + objectName;
executeAndLog(
...
...
@@ -1999,36 +2043,57 @@ public class ManageSqlConf extends ActionHandlerEJB {
*/
String grantSql = null;
//For Pilot transaction Create Table query grant rights of SELECT, INSERT, UPDATE, DELETE
// 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)) {
grantSql = "GRANT SELECT, INSERT, UPDATE, DELETE ON "
+ dbMain + "." + objectName
+
" TO "
+
schemaName
;
+ " TO " +
targetSchema
;
} else {
grantSql = "GRANT SELECT ON "
+ dbMain + "." + objectName
+
" TO "
+
schemaName
;
+ " TO " +
targetSchema
;
}
}
else
if
(
"VIEW"
.
equalsIgnoreCase
(
createObjectType
)
} else if ("VIEW".equalsIgnoreCase(createObjectType)
|| "SEQUENCE".equalsIgnoreCase(createObjectType)) {
grantSql
=
"GRANT SELECT ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
schemaName
;
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
grantSql = "GRANT SELECT ON "
+ dbMain + "." + objectName
+ " TO " + targetSchema;
} else if ("PROCEDURE".equalsIgnoreCase(createObjectType)
|| "FUNCTION".equalsIgnoreCase(createObjectType)
|| "PACKAGE".equalsIgnoreCase(createObjectType)
|| "TYPE".equalsIgnoreCase(createObjectType)) {
grantSql
=
"GRANT EXECUTE ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
schemaName
;
targetSchema = ("P".equalsIgnoreCase(execRights)
&& schemaName.equalsIgnoreCase(dbPilot))
? schemaForPilot
: schemaName;
grantSql = "GRANT EXECUTE ON "
+ dbMain + "." + objectName
+ " TO " + targetSchema;
}
BaseLogger.log(
"3",
...
...
@@ -2051,21 +2116,22 @@ public class ManageSqlConf extends ActionHandlerEJB {
"3",
null,
null,
"dbRead ["
+
dbRead
+
"]"
);
if
(
grantSql
!=
null
)
{
executeAndLog
(
schemaName
,
grantSql
,
tranId
,
enterpriseCode
,
linNo
,
requestID
,
userId
,
chgTerm
,
dbMain
,
""
,
false
);
}
"dbRead [[" + dbRead + "]");
if (grantSql != null) {
executeAndLog(
schemaName,
grantSql,
tranId,
enterpriseCode,
linNo,
requestID,
userId,
chgTerm,
dbMain,
"",
false);
}
}
continue; // Skip DML flow
...
...
@@ -2097,6 +2163,16 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
System.out.println("Execution completed successfully.");
}
catch(Exception e){
String error = (e.getMessage() != null)
? 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
...
...
@@ -2130,24 +2206,24 @@ public class ManageSqlConf extends ActionHandlerEJB {
String schemaForPilot = "";
BaseLogger.log("3", null, null, "executeAndLog inputSql: [" + inputSql + "]");
BaseLogger.log("3", null, null, "executeAndLog execRights: [" + execRights + "]");
//
Changes by Ajit D. on 08-JUNE-26 for Pilot Transaction schema name fetched it
from USERS
if
(
execRights
.
trim
().
equalsIgnoreCase
(
"P"
))
{
// Changes by Ajit D. on 08-JUNE-26 for Pilot Transaction schema name fetched it
// from USERS
if (execRights.trim().equalsIgnoreCase("P"))
{
BaseLogger.log("3", null, null, "For Pilot schemaName: [" + schemaName + "]");
BaseLogger.log("3", null, null, "executeAndLog inputSql: [" + inputSql + "]");
connForPilotSchema = connDriverForPilotSchema.getConnectDB(schemaName);
String schemaForPilotSql = "SELECT USER FROM DUAL";
PreparedStatement schemaForPilotPs = connForPilotSchema.prepareStatement(schemaForPilotSql);
ResultSet schemaForPilotRs = schemaForPilotPs.executeQuery();
while
(
schemaForPilotRs
.
next
())
{
while
(schemaForPilotRs.next())
{
schemaForPilot = checkNull(schemaForPilotRs.getString("USER"));
}
BaseLogger
.
log
(
"3"
,
null
,
null
,
"schemaForPilot: ["
+
schemaForPilot
+
"]"
);
BaseLogger.log("3", null, null, "schemaForPilot: [" + schemaForPilot + "]");
schemaName = schemaForPilot;
}
String finalSql = applySchema(inputSql, schemaName);
...
...
@@ -2190,8 +2266,7 @@ public class ManageSqlConf extends ActionHandlerEJB {
connForExec = connForExecRs.getString("schema_name");
}
if
(
execRights
.
trim
().
equalsIgnoreCase
(
"P"
)
||
execRights
.
trim
().
equalsIgnoreCase
(
"C"
)){
if (execRights.trim().equalsIgnoreCase("P") || execRights.trim().equalsIgnoreCase("C")) {
connForExec = schemaName;
}
System.out.println("connForExec:: " + connForExec);
...
...
@@ -2296,8 +2371,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
finalSql, updCount, "E", userId, chgTerm, error, dbMainSchema);
// if (rethrow) {
//
System.out.println("In rethrow condition");
//
throw new RuntimeException(e);
// System.out.println("In rethrow condition");
// throw new RuntimeException(e);
// }
} finally {
if (connForExecRs != null)
...
...
@@ -2531,7 +2606,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
// TRIGGER: ON table
// FIX IS HERE: Added \\b before ON
// This prevents matching "actiON", "positiON", "unicON", etc.
//Updated the logic to appent the placeholder ( {SCHEMA} ) before the trigger name.
// Updated the logic to appent the placeholder ( {SCHEMA} ) before the trigger
// name.
String upper = s.toUpperCase();
if (upper.startsWith("TRIGGER ")
...
...
@@ -2626,8 +2702,8 @@ public class ManageSqlConf extends ActionHandlerEJB {
}
// Remove EDITIONABLE / NONEDITIONABLE keywords
s
=
s
.
replaceFirst
(
"CREATE\\s+NONEDITIONABLE\\s+"
,
"CREATE "
);
s
=
s
.
replaceFirst
(
"CREATE\\s+EDITIONABLE\\s+"
,
"CREATE "
);
s = s.replaceFirst("CREATE\\s+NONEDITIONABLE\\s+", "CREATE ");
s = s.replaceFirst("CREATE\\s+EDITIONABLE\\s+", "CREATE ");
if (s.startsWith("CREATE TABLE"))
return "TABLE";
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment