Commit e926c306 authored by vvengurlekar's avatar vvengurlekar

TrainexecCnf.java - connection related chnages done in file


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@201680 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c012fd65
...@@ -9,15 +9,20 @@ ...@@ -9,15 +9,20 @@
package ibase.webitm.ejb.adm.adv; package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.*; import java.sql.Connection;
import javax.ejb.*; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import ibase.webitm.utility.ITMException; //import ibase.webitm.utility.GenericUtility;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
@Stateless // added for ejb3 @Stateless // added for ejb3
public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,TrainexecCnfRemote //SessionBean public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,TrainexecCnfRemote //SessionBean
...@@ -44,7 +49,6 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -44,7 +49,6 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
} }
public String confirm(String trainNo, String xtraParams, String forcedFlag) throws RemoteException,ITMException public String confirm(String trainNo, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{ {
String retString = ""; String retString = "";
try try
{ {
...@@ -72,20 +76,24 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -72,20 +76,24 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
Statement stmt = null; Statement stmt = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); //ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
GenericUtility genericUtility = GenericUtility.getInstance(); //Changed by Varsha V on 06-06-19 for GenericUtility purpose[START]
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
//Changed by Varsha V on 06-06-19 for GenericUtility purpose[END]
int cnt = 0; int cnt = 0;
try try
{ {
batchNo = trainNo.substring(trainNo.indexOf(":")+1); batchNo = trainNo.substring(trainNo.indexOf(":")+1);
trainNo = trainNo.substring(0,trainNo.indexOf(":")); trainNo = trainNo.substring(0,trainNo.indexOf(":"));
System.out.println("Batch No :"+ batchNo); System.out.println("Batch No :"+ batchNo);
System.out.println("Train No :"+ trainNo); System.out.println("Train No :"+ trainNo);
//Changed by Varsha V on 06-06-19 for connection purpose[START]
conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changed by Varsha V on 06-06-19 for connection purpose[END]
conn.setAutoCommit(false); conn.setAutoCommit(false);
//INTO :LS_CONFIRMED, :LS_TRAIN_CODE, :LD_START //INTO :LS_CONFIRMED, :LS_TRAIN_CODE, :LD_START
sql = "SELECT CONFIRM, TRAIN_CODE , START_DATE " + sql = "SELECT CONFIRM, TRAIN_CODE , START_DATE " +
...@@ -102,7 +110,16 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -102,7 +110,16 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
trainCode = rs.getString(2); trainCode = rs.getString(2);
startDate = rs.getDate(3); startDate = rs.getDate(3);
} }
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (confirmed.trim().equalsIgnoreCase("N")) if (confirmed.trim().equalsIgnoreCase("N"))
{ {
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
...@@ -131,13 +148,29 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -131,13 +148,29 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
{ {
startPrd = rs.getString(1); startPrd = rs.getString(1);
} }
//Changed by Varsha V on 06-06-19 for connection purpose[START]
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Changed by Varsha V on 06-06-19 for connection purpose[END]
sql = "SELECT COMM_CATG, EMP_CODE " + sql = "SELECT COMM_CATG, EMP_CODE " +
"FROM TRAINEMP " + "FROM TRAINEMP " +
"WHERE TRAIN_NO = '" + trainNo + "'" + "WHERE TRAIN_NO = '" + trainNo + "'" +
"AND BATCH_NO = '" + batchNo + "'" ; "AND BATCH_NO = '" + batchNo + "'" ;
stmt = conn.createStatement(); stmt = conn.createStatement();
rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
if(stmt != null)
{
stmt.close();
stmt = null;
}
sql = "UPDATE TRAINNEED " + sql = "UPDATE TRAINNEED " +
"SET STATUS = 'U'," + "SET STATUS = 'U'," +
"STATUS_DATE = ?," + "STATUS_DATE = ?," +
...@@ -161,6 +194,18 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -161,6 +194,18 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
pstmt.setString(7, startPrd); pstmt.setString(7, startPrd);
cnt += pstmt.executeUpdate(); cnt += pstmt.executeUpdate();
} }
//Changed by Varsha V on 06-06-19 for connection purpose[START]
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Changed by Varsha V on 06-06-19 for connection purpose[END]
if (cnt > 0) if (cnt > 0)
{ {
errCode = "VTMCONF2"; errCode = "VTMCONF2";
...@@ -197,6 +242,18 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal, ...@@ -197,6 +242,18 @@ public class TrainexecCnf extends ActionHandlerEJB implements TrainexecCnfLocal,
{ {
if (conn!=null) if (conn!=null)
{ {
//Changed by Varsha V on 06-06-19 for connection purpose[START]
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Changed by Varsha V on 06-06-19 for connection purpose[END]
conn.close(); conn.close();
conn = null; conn = 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