Commit 2aa401b9 authored by vvengurlekar's avatar vvengurlekar

GlOpenConf.java - connection rollback added in catch block


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@191609 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1ce08948
...@@ -44,7 +44,7 @@ public class GlOpenConf extends ActionHandlerEJB implements GlOpenConfLocal,GlO ...@@ -44,7 +44,7 @@ public class GlOpenConf extends ActionHandlerEJB implements GlOpenConfLocal,GlO
System.out.println("Returning Result ::"+result); System.out.println("Returning Result ::"+result);
return result; return result;
} }
private String confirmGlOpenConf(String tranID,String xtraParams)throws RemoteException,ITMException private String confirmGlOpenConf(String tranID,String xtraParams)throws RemoteException,ITMException, SQLException
{ {
Connection conn = null; Connection conn = null;
//Statement stmt = null; //Statement stmt = null;
...@@ -96,14 +96,16 @@ public class GlOpenConf extends ActionHandlerEJB implements GlOpenConfLocal,GlO ...@@ -96,14 +96,16 @@ public class GlOpenConf extends ActionHandlerEJB implements GlOpenConfLocal,GlO
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
String empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"); String empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId"); //Commented and added by varsha v on 04-10-18 for taking loginCode as userId
//userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
//Commented and ended by varsha v on 04-10-18 for taking loginCode as userId
try try
{ {
//Changes and Commented By Bhushan on 06-06-2016 :START //Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM"); //conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END //Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); //Gulzar 06-12-06 conn.setAutoCommit(false); //Gulzar 06-12-06
} }
catch(Exception ex) catch(Exception ex)
...@@ -143,6 +145,16 @@ conn = getConnection(); ...@@ -143,6 +145,16 @@ conn = getConnection();
System.out.println("SQLException [04][GlOpenConf][Excuting Query Failed]" + sql + se.getMessage()); System.out.println("SQLException [04][GlOpenConf][Excuting Query Failed]" + sql + se.getMessage());
se.printStackTrace(); se.printStackTrace();
retString = se.getMessage(); retString = se.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e)
{
System.out.println("Exception --["+ e.getMessage()+"]");
}
//Ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
catch(Exception e) catch(Exception e)
...@@ -150,6 +162,16 @@ conn = getConnection(); ...@@ -150,6 +162,16 @@ conn = getConnection();
System.out.println("Exception [05][GlOpenConf][Excuting Query Failed]" + sql + e.getMessage()); System.out.println("Exception [05][GlOpenConf][Excuting Query Failed]" + sql + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
finally finally
...@@ -172,6 +194,16 @@ conn = getConnection(); ...@@ -172,6 +194,16 @@ conn = getConnection();
System.out.println("Exception [06][GlOpenConf]" + e.getMessage()); System.out.println("Exception [06][GlOpenConf]" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
System.out.println("Exception In Closing Statement and ResultSet" + retString); System.out.println("Exception In Closing Statement and ResultSet" + retString);
return retString; return retString;
} }
...@@ -232,6 +264,16 @@ conn = getConnection(); ...@@ -232,6 +264,16 @@ conn = getConnection();
System.out.println("SQLException [04][GlOpenConf][Excuting Query Failed]" + sql + se.getMessage()); System.out.println("SQLException [04][GlOpenConf][Excuting Query Failed]" + sql + se.getMessage());
se.printStackTrace(); se.printStackTrace();
retString = se.getMessage(); retString = se.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e)
{
System.out.println("Exception --["+ e.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
catch(Exception e) catch(Exception e)
...@@ -239,6 +281,16 @@ conn = getConnection(); ...@@ -239,6 +281,16 @@ conn = getConnection();
System.out.println("Exception [05][GlOpenConf][Excuting Query Failed]" + sql + e.getMessage()); System.out.println("Exception [05][GlOpenConf][Excuting Query Failed]" + sql + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
finally finally
...@@ -261,6 +313,16 @@ conn = getConnection(); ...@@ -261,6 +313,16 @@ conn = getConnection();
System.out.println("Exception [06][GlOpenConf]" + e.getMessage()); System.out.println("Exception [06][GlOpenConf]" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
System.out.println("Exception In Closing Statement and ResultSet" + retString); System.out.println("Exception In Closing Statement and ResultSet" + retString);
return retString; return retString;
} }
...@@ -276,20 +338,22 @@ conn = getConnection(); ...@@ -276,20 +338,22 @@ conn = getConnection();
"VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )"; "VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,? )";
System.out.println("Inserting Into ACCTBAL FOR 000000 :: "+sqlIns); System.out.println("Inserting Into ACCTBAL FOR 000000 :: "+sqlIns);
pstmt = conn.prepareStatement(sqlIns); pstmt = conn.prepareStatement(sqlIns);
pstmt.setString(1,acctPrd); //added by varsha v on 04-10-18 add checknull
pstmt.setString(1,checkNull(acctPrd));
pstmt.setString(2,"000000"); pstmt.setString(2,"000000");
pstmt.setString(3,finEnt); pstmt.setString(3,checkNull(finEnt));
pstmt.setString(4,siteCode); pstmt.setString(4,checkNull(siteCode));
pstmt.setString(5,acctCode); pstmt.setString(5,checkNull(acctCode));
pstmt.setString(6,cctrCode); pstmt.setString(6,checkNull(cctrCode));
pstmt.setDouble(7,drAmt); pstmt.setDouble(7,drAmt);
pstmt.setDouble(8,crAmt); pstmt.setDouble(8,crAmt);
pstmt.setString(9,currCode); pstmt.setString(9,checkNull(currCode));
pstmt.setDouble(10,drAmtBase); pstmt.setDouble(10,drAmtBase);
pstmt.setDouble(11,crAmtBase); pstmt.setDouble(11,crAmtBase);
pstmt.setTimestamp(12,new java.sql.Timestamp(System.currentTimeMillis())); pstmt.setTimestamp(12,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(13,chgUser); pstmt.setString(13,checkNull(chgUser));
pstmt.setString(14,chgTerm); pstmt.setString(14,checkNull(chgTerm));
//ended by varsha v on 04-10-18 add checknull
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
...@@ -315,6 +379,16 @@ conn = getConnection(); ...@@ -315,6 +379,16 @@ conn = getConnection();
System.out.println("Exception [11][GlOpenConf][Insert Query Failed]" + sqlIns + e.getMessage()); System.out.println("Exception [11][GlOpenConf][Insert Query Failed]" + sqlIns + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
finally finally
...@@ -332,6 +406,16 @@ conn = getConnection(); ...@@ -332,6 +406,16 @@ conn = getConnection();
System.out.println("Exception [12][GlOpenConf]" + sqlIns + e.getMessage()); System.out.println("Exception [12][GlOpenConf]" + sqlIns + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception --["+ e1.getMessage()+"]");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
} }
...@@ -347,20 +431,22 @@ conn = getConnection(); ...@@ -347,20 +431,22 @@ conn = getConnection();
System.out.println("Inserting Into ACCTBAL FOR zzzzzz :: "+sqlIns); System.out.println("Inserting Into ACCTBAL FOR zzzzzz :: "+sqlIns);
pstmt = conn.prepareStatement(sqlIns); pstmt = conn.prepareStatement(sqlIns);
pstmt.setString(1,acctPrd); //added by varsha v on 04-10-18 add checknull
pstmt.setString(1,checkNull(acctPrd));
pstmt.setString(2,"zzzzzz"); pstmt.setString(2,"zzzzzz");
pstmt.setString(3,finEnt); pstmt.setString(3,checkNull(finEnt));
pstmt.setString(4,siteCode); pstmt.setString(4,checkNull(siteCode));
pstmt.setString(5,acctCode); pstmt.setString(5,checkNull(acctCode));
pstmt.setString(6,cctrCode); pstmt.setString(6,checkNull(cctrCode));
pstmt.setDouble(7,drAmt); pstmt.setDouble(7,drAmt);
pstmt.setDouble(8,crAmt); pstmt.setDouble(8,crAmt);
pstmt.setString(9,currCode); pstmt.setString(9,checkNull(currCode));
pstmt.setDouble(10,drAmtBase); pstmt.setDouble(10,drAmtBase);
pstmt.setDouble(11,crAmtBase); pstmt.setDouble(11,crAmtBase);
pstmt.setTimestamp(12,new java.sql.Timestamp(System.currentTimeMillis())); pstmt.setTimestamp(12,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(13,chgUser); pstmt.setString(13,checkNull(chgUser));
pstmt.setString(14,chgTerm); pstmt.setString(14,checkNull(chgTerm));
//added by varsha v on 04-10-18 add checknull
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
...@@ -386,6 +472,16 @@ conn = getConnection(); ...@@ -386,6 +472,16 @@ conn = getConnection();
System.out.println("Exception [11][GlOpenConf][Insert Query Failed]" + sqlIns + e.getMessage()); System.out.println("Exception [11][GlOpenConf][Insert Query Failed]" + sqlIns + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
finally finally
...@@ -403,6 +499,16 @@ conn = getConnection(); ...@@ -403,6 +499,16 @@ conn = getConnection();
System.out.println("Exception [12][GlOpenConf]" + sqlIns + e.getMessage()); System.out.println("Exception [12][GlOpenConf]" + sqlIns + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
} }
...@@ -478,6 +584,16 @@ conn = getConnection(); ...@@ -478,6 +584,16 @@ conn = getConnection();
System.out.println("Exception [11][GlOpenConf][Update Query Failed]" + sqlUpd + e.getMessage()); System.out.println("Exception [11][GlOpenConf][Update Query Failed]" + sqlUpd + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
finally finally
...@@ -495,6 +611,16 @@ conn = getConnection(); ...@@ -495,6 +611,16 @@ conn = getConnection();
System.out.println("Exception [12][GlOpenConf]" + sqlUpd + e.getMessage()); System.out.println("Exception [12][GlOpenConf]" + sqlUpd + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
}//Finally Block }//Finally Block
...@@ -535,6 +661,16 @@ conn = getConnection(); ...@@ -535,6 +661,16 @@ conn = getConnection();
se.printStackTrace(); se.printStackTrace();
conn.rollback(); conn.rollback();
retString = se.getMessage(); retString = se.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
catch(Exception e) catch(Exception e)
...@@ -543,6 +679,16 @@ conn = getConnection(); ...@@ -543,6 +679,16 @@ conn = getConnection();
conn.rollback(); conn.rollback();
System.out.println("Exception[17] ::"+e.getMessage()); System.out.println("Exception[17] ::"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
retString = "Not Confirmed :" + e.getMessage(); retString = "Not Confirmed :" + e.getMessage();
} }
finally finally
...@@ -560,6 +706,16 @@ conn = getConnection(); ...@@ -560,6 +706,16 @@ conn = getConnection();
System.out.println("SQLException [18] Connection Error Closed :" + se.getMessage()); System.out.println("SQLException [18] Connection Error Closed :" + se.getMessage());
se.printStackTrace(); se.printStackTrace();
retString = "Connection Not Closed :" + se.getMessage(); retString = "Connection Not Closed :" + se.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
}//finally }//finally
...@@ -601,6 +757,16 @@ conn = getConnection(); ...@@ -601,6 +757,16 @@ conn = getConnection();
System.out.println("Exception [20][confirmGlOpenConf]" + e.getMessage()); System.out.println("Exception [20][confirmGlOpenConf]" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
retString = e.getMessage(); retString = e.getMessage();
//added by varsha v on 04-10-18 to rollback connnection if exceptiion caught
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception In Rollback Transaction");
}
//ended by varsha v on 04-10-18 to rollback connnection if exceptiion caught
return retString; return retString;
} }
}// Finally Block }// Finally Block
...@@ -608,7 +774,7 @@ conn = getConnection(); ...@@ -608,7 +774,7 @@ conn = getConnection();
System.out.println("retString ::"+retString); System.out.println("retString ::"+retString);
return retString; return retString;
} }
private boolean dupConf(String tarnID,Connection conn) throws ITMException private boolean dupConf(String tarnID,Connection conn) throws ITMException, SQLException
{ {
//Statement stmt = null; //Statement stmt = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -644,6 +810,35 @@ conn = getConnection(); ...@@ -644,6 +810,35 @@ conn = getConnection();
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
//added by varsha v on 04-10-18 finally block added
finally
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
//added by varsha v on 04-10-18 finally block added
return flag; return flag;
} }
// added checkNull method by varsha v on 4-10-18
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
//ended checkNull method by varsha v on 4-10-18
} }
\ No newline at end of file
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