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

Replace ManageSqlReleaseFromQC.java

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