Commit c9eda4db authored by arawankar's avatar arawankar

Changes made in miscVoucherPostSave.java

1.Connection related issue 

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@182965 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c684b17e
......@@ -275,6 +275,32 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
e1.printStackTrace();
}
}
//Modified by Anjali R. on[03/04/2018][To avoid resource lean issue][Start]
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
System.out.println(":::: " + this.getClass().getSimpleName() + "::: " + e.getMessage());
e.printStackTrace();
}
}
//Modified by Anjali R. on[03/04/2018][To avoid resource lean issue][End]
System.out.println("Out MiscVoucherPostSaveEJB ... ");
return "";
}
......@@ -294,6 +320,11 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
throws ITMException {
PreparedStatement pstmt = null;
//Added by Anjali R. on[03/04/2018][Start]
PreparedStatement pstmt1 = null;
String sql1 = "";
//Added by Anjali R. on[03/04/2018][End]
ResultSet rs = null;
String sql = "", varValue = "",tranId = "", refSer = "", refNo = "";
double totAmtPayAbs = 0.0, adjAmtPayAbs = 0.0, adjAmt = 0.0, totAmtTemp = 0.0;
......@@ -309,6 +340,9 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
pstmt.executeUpdate();
totAmtTemp = totAmt;
//Added by Anjali R. on[02/04/2018][To avoid resource leak issue][Start]
closeResources(pstmt, rs);
//Added by Anjali R. on[02/04/2018][To avoid resource leak issue][End]
sql = "select var_value from finparm where var_name = 'ADV_ADJ_ACCT_CODE' ";
pstmt = conn.prepareStatement(sql);
......@@ -319,12 +353,21 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
}
varValue = varValue == null ? "" : varValue.trim();
System.out.println("var value ::: " + varValue);
//Added by Anjali R. on[02/04/2018][To avoid resource leak issue][Start]
closeResources(pstmt, rs);
//Added by Anjali R. on[02/04/2018][To avoid resource leak issue][End]
sql = "select tran_id,tran_ser,ref_no,tot_amt,adj_amt,curr_code,acct_code,cctr_code,exch_rate from misc_payables where site_code = ? and sundry_type = ? and sundry_code = ? " +
"and tot_amt <> adj_amt and tot_amt < 0 and acct_code in ("+ varValue + ") order by tran_date";
pstmt = conn.prepareStatement(sql);
//Modified by Anjali R. on[03/04/2018][Start]
sql1 = "Insert into misc_vouchadv(tran_id,ref_ser,ref_no,adj_amt,tot_amt,line_no,curr_code,acct_code,cctr_code,exch_rate__vouch) values(?,?,?,?,?,?,?,?,?,?)";// TODO insert
pstmt1 = conn.prepareStatement(sql1);
//Modified by Anjali R. on[03/04/2018][End]
pstmt.setString(1, siteCode);
pstmt.setString(2, sundryType);
pstmt.setString(3, sundryCode);
......@@ -369,22 +412,29 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
System.out.println("total amount temp:: " + totAmtTemp);
if(adjAmtAbs > 0){
sql = "Insert into misc_vouchadv(tran_id,ref_ser,ref_no,adj_amt,tot_amt,line_no,curr_code,acct_code,cctr_code,exch_rate__vouch) values(?,?,?,?,?,?,?,?,?,?)";// TODO insert
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tran_id);
pstmt.setString(2, refSer);
pstmt.setString(3, refNo);
pstmt.setDouble(4, adjAmt);
pstmt.setDouble(5, totAmtPay);
pstmt.setInt(6, lineNo);
pstmt.setString(7, currCodePay);
pstmt.setString(8, acctCode);
pstmt.setString(9, cctrCode);
pstmt.setString(10, exchRate);
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if(adjAmtAbs > 0)
{
//Modified by Anjali R. on[03/04/2018][sql statement written before while loop][Start]
/*sql = "Insert into misc_vouchadv(tran_id,ref_ser,ref_no,adj_amt,tot_amt,line_no,curr_code,acct_code,cctr_code,exch_rate__vouch) values(?,?,?,?,?,?,?,?,?,?)";// TODO insert
pstmt = conn.prepareStatement(sql);*/
//Modified by Anjali R. on[03/04/2018][sql statement written before while loop][End]
pstmt1.setString(1, tran_id);
pstmt1.setString(2, refSer);
pstmt1.setString(3, refNo);
pstmt1.setDouble(4, adjAmt);
pstmt1.setDouble(5, totAmtPay);
pstmt1.setInt(6, lineNo);
pstmt1.setString(7, currCodePay);
pstmt1.setString(8, acctCode);
pstmt1.setString(9, cctrCode);
pstmt1.setString(10, exchRate);
pstmt1.executeUpdate();
//Modified by Anjali R. on[03/04/2018][clear parameter of prepared statement][Start]
pstmt1.clearParameters();
/*pstmt.close();
pstmt = null;*/
//Modified by Anjali R. on[03/04/2018][clear parameter of prepared statement][End]
}
lineNo++;
......@@ -393,7 +443,11 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
}
}
//Modified by Anjali R. on[03/04/2018][to avoid resource leak issue][Start]
closeResources(pstmt, rs);
closeResources(pstmt1, rs);
//Modified by Anjali R. on[03/04/2018][to avoid resource leak issue][End]
} catch (Exception e) {
System.out.println(":::: " + this.getClass().getSimpleName() + "::: " + e.getMessage());
e.printStackTrace();
......@@ -410,6 +464,13 @@ public class MiscVoucherPostSave extends ValidatorEJB implements MiscVoucherPost
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[03/04/2018][To avoid resource leak issue][Start]
if (pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
//Modified by Anjali R. on[03/04/2018][To avoid resource leak issue][End]
} catch (Exception e) {
System.out.println(":::: " + this.getClass().getSimpleName() + "::: " + e.getMessage());
e.printStackTrace();
......
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