Commit 3d7b5e2d authored by Ajit Deshmukh's avatar Ajit Deshmukh

Replace ManageSqlReleaseFromQC.java

parent eaa90bb9
...@@ -325,23 +325,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB { ...@@ -325,23 +325,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB {
Connection pilotEntConn = null; Connection pilotEntConn = null;
PreparedStatement pilotPstmt = null; PreparedStatement pilotPstmt = null;
ResultSet pilotRs = null; ResultSet pilotRs = null;
StringBuilder dbPilotBuilder = new StringBuilder();
try { try {
ConnDriver pilotConnDriver = new ConnDriver(); ConnDriver pilotConnDriver = new ConnDriver();
pilotEntConn = pilotConnDriver.getConnectDB("Driver"); pilotEntConn = pilotConnDriver.getConnectDB("Driver");
// Use the first enterprise from the original transaction to look up DB_PILOT String[] entArray = enterprises.split(",");
String entForLookup = enterprises;
if (entForLookup.contains(",")) {
entForLookup = entForLookup.split(",")[0].trim();
}
String pilotSql = "SELECT DB_PILOT FROM ENTERPRISE WHERE ENTERPRISE = ?"; String pilotSql = "SELECT DB_PILOT FROM ENTERPRISE WHERE ENTERPRISE = ?";
pilotPstmt = pilotEntConn.prepareStatement(pilotSql); pilotPstmt = pilotEntConn.prepareStatement(pilotSql);
pilotPstmt.setString(1, entForLookup);
for (String ent : entArray) {
ent = ent.trim();
pilotPstmt.setString(1, ent);
pilotRs = pilotPstmt.executeQuery(); pilotRs = pilotPstmt.executeQuery();
if (pilotRs.next()) { if (pilotRs.next()) {
dbPilotEnterprise = checkNull(pilotRs.getString("DB_PILOT")); String dbPilot = checkNull(pilotRs.getString("DB_PILOT"));
if (dbPilot != null && !dbPilot.isEmpty()) {
if (dbPilotBuilder.length() > 0) {
dbPilotBuilder.append(",");
} }
dbPilotBuilder.append(dbPilot);
}
}
if (pilotRs != null)
pilotRs.close(); // important inside loop
}
dbPilotEnterprise = dbPilotBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
} finally { } finally {
if (pilotRs != null) { if (pilotRs != null) {
...@@ -461,23 +480,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB { ...@@ -461,23 +480,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB {
Connection clientDevEntConn = null; Connection clientDevEntConn = null;
PreparedStatement clientDevPstmt = null; PreparedStatement clientDevPstmt = null;
ResultSet clientDevRs = null; ResultSet clientDevRs = null;
StringBuilder dbClientDevBuilder = new StringBuilder();
try { try {
ConnDriver clientDevConnDriver = new ConnDriver(); ConnDriver clientDevConnDriver = new ConnDriver();
clientDevEntConn = clientDevConnDriver.getConnectDB("Driver"); clientDevEntConn = clientDevConnDriver.getConnectDB("Driver");
// Use the first enterprise from the original transaction to look up DB_PILOT String[] entArray = enterprises.split(",");
String entForLookup = enterprises;
if (entForLookup.contains(",")) {
entForLookup = entForLookup.split(",")[0].trim();
}
String clientDevSql = "SELECT DB_DEV FROM ENTERPRISE WHERE ENTERPRISE = ?"; String clientDevSql = "SELECT DB_DEV FROM ENTERPRISE WHERE ENTERPRISE = ?";
clientDevPstmt = clientDevEntConn.prepareStatement(clientDevSql); clientDevPstmt = clientDevEntConn.prepareStatement(clientDevSql);
clientDevPstmt.setString(1, entForLookup);
for (String ent : entArray) {
ent = ent.trim();
clientDevPstmt.setString(1, ent);
clientDevRs = clientDevPstmt.executeQuery(); clientDevRs = clientDevPstmt.executeQuery();
if (clientDevRs.next()) { if (clientDevRs.next()) {
dbClientDevEnterprise = checkNull(clientDevRs.getString("DB_DEV")); String dbDev = checkNull(clientDevRs.getString("DB_DEV"));
if (dbDev != null && !dbDev.isEmpty()) {
if (dbClientDevBuilder.length() > 0) {
dbClientDevBuilder.append(",");
}
dbClientDevBuilder.append(dbDev);
} }
}
if (clientDevRs != null)
clientDevRs.close(); // close inside loop
}
dbClientDevEnterprise = dbClientDevBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
} finally { } finally {
if (clientDevRs != null) { if (clientDevRs != null) {
clientDevRs.close(); clientDevRs.close();
...@@ -614,23 +652,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB { ...@@ -614,23 +652,42 @@ public class ManageSqlReleaseFromQC extends ActionHandlerEJB {
Connection liveEntConn = null; Connection liveEntConn = null;
PreparedStatement livePstmt = null; PreparedStatement livePstmt = null;
ResultSet liveRs = null; ResultSet liveRs = null;
StringBuilder dbLiveBuilder = new StringBuilder();
try { try {
ConnDriver liveEntConnConnDriver = new ConnDriver(); ConnDriver liveEntConnConnDriver = new ConnDriver();
liveEntConn = liveEntConnConnDriver.getConnectDB("Driver"); liveEntConn = liveEntConnConnDriver.getConnectDB("Driver");
// Use the first enterprise from the original transaction to look up DB_PILOT String[] entArray = enterprises.split(",");
String entForLookup = enterprises;
if (entForLookup.contains(",")) { String liveSql = "SELECT DB_MAIN FROM ENTERPRISE WHERE ENTERPRISE = ?";
entForLookup = entForLookup.split(",")[0].trim(); livePstmt = liveEntConn.prepareStatement(liveSql);
}
for (String ent : entArray) {
ent = ent.trim();
String clientDevSql = "SELECT DB_MAIN FROM ENTERPRISE WHERE ENTERPRISE = ?"; livePstmt.setString(1, ent);
livePstmt = liveEntConn.prepareStatement(clientDevSql);
livePstmt.setString(1, entForLookup);
liveRs = livePstmt.executeQuery(); liveRs = livePstmt.executeQuery();
if (liveRs.next()) { if (liveRs.next()) {
dbLiveEnterprise = checkNull(liveRs.getString("DB_MAIN")); String dbMain = checkNull(liveRs.getString("DB_MAIN"));
if (dbMain != null && !dbMain.isEmpty()) {
if (dbLiveBuilder.length() > 0) {
dbLiveBuilder.append(",");
}
dbLiveBuilder.append(dbMain);
}
}
if (liveRs != null)
liveRs.close(); // close inside loop
} }
dbLiveEnterprise = dbLiveBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
} finally { } finally {
if (liveRs != null) { if (liveRs != null) {
liveRs.close(); liveRs.close();
......
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