Commit 25157dfa authored by arawankar's avatar arawankar

-Connection closing related changes made in below components

MiscVoucherAct.java
VouchPayAct.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189965 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9e1a6b2e
...@@ -38,7 +38,7 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo ...@@ -38,7 +38,7 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo
{ {
return ""; return "";
} }
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException
{ {
Document dom = null; Document dom = null;
...@@ -56,14 +56,14 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo ...@@ -56,14 +56,14 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo
resString = actionDefault(dom,objContext,xtraParams); resString = actionDefault(dom,objContext,xtraParams);
} }
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("returning from actionVoucher actionHandler"+resString); System.out.println("returning from actionVoucher actionHandler"+resString);
return resString; return resString;
} }
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException
{ {
...@@ -74,19 +74,38 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo ...@@ -74,19 +74,38 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo
conn=getConnection(); conn=getConnection();
VouchPayAct vouchpay=new VouchPayAct(); VouchPayAct vouchpay=new VouchPayAct();
resString=vouchpay.actionPay(tranId, xtraParams, "M-VOUC",false,conn); resString=vouchpay.actionPay(tranId, xtraParams, "M-VOUC",false,conn);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
//Modified by Anjali R. on [28/08/2018][connection was not close][start]
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception ex)
{
System.out.println("Exception in actionHandler--["+ ex.getMessage() +"]");
ex.printStackTrace();
}
}
//Modified by Anjali R. on [28/08/2018][connection was not close][End]
System.out.println("returning from actionVoucher actionHandler"+resString); System.out.println("returning from actionVoucher actionHandler"+resString);
return resString; return resString;
} }
private String actionDefault(Document dom, String objContext, String xtraParams) throws RemoteException , ITMException private String actionDefault(Document dom, String objContext, String xtraParams) throws RemoteException , ITMException
{ {
String sundryType = "", sql = "", detCnt = "0", empCode = "", sundryCode = "", cctrCode = "", acctCode ="", grade = "", billNo = "", billDate = ""; String sundryType = "", sql = "", detCnt = "0", empCode = "", sundryCode = "", cctrCode = "", acctCode ="", grade = "", billNo = "", billDate = "";
...@@ -105,9 +124,9 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo ...@@ -105,9 +124,9 @@ public class MiscVoucherAct extends ActionHandlerEJB implements MiscVoucherActLo
if (detCnt.equals("0")) if (detCnt.equals("0"))
{ {
//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
stmt = conn.createStatement(); stmt = conn.createStatement();
sundryType = genericUtility.getColumnValue("sundry_type",dom); sundryType = genericUtility.getColumnValue("sundry_type",dom);
...@@ -228,7 +247,7 @@ conn = getConnection(); ...@@ -228,7 +247,7 @@ conn = getConnection();
int metaDataNodeListLen = metaDataList.getLength(); int metaDataNodeListLen = metaDataList.getLength();
int importedListLen = importedList.getLength(); int importedListLen = importedList.getLength();
System.out.println("\n metaDataNodeListLen :"+metaDataNodeListLen+"\n importedListLen :"+importedListLen); System.out.println("\n metaDataNodeListLen :"+metaDataNodeListLen+"\n importedListLen :"+importedListLen);
//Added by jiten //Added by jiten
boolean flag = false; boolean flag = false;
NodeList childNodeList = null; NodeList childNodeList = null;
......
...@@ -31,7 +31,7 @@ import org.w3c.dom.Document; ...@@ -31,7 +31,7 @@ import org.w3c.dom.Document;
@Stateless @Stateless
public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, VouchPayActRemote public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, VouchPayActRemote
{ {
String userId = "", termId = ""; String userId = "", termId = "";
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
...@@ -44,17 +44,35 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -44,17 +44,35 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
conn = getConnection(); conn = getConnection();
resString = actionPay(tranId,xtraParams,"VOUCH",false,conn); resString = actionPay(tranId,xtraParams,"VOUCH",false,conn);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :MiscVoucher :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
//Modified by Anjali R. on [28/08/2018][connection was not close][start]
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception ex)
{
System.out.println("Exception in actionHandler--["+ ex.getMessage() +"]");
ex.printStackTrace();
}
}
//Modified by Anjali R. on [28/08/2018][connection was not close][End]
System.out.println("returning from actionVoucher actionHandler"+resString); System.out.println("returning from actionVoucher actionHandler"+resString);
return resString; return resString;
} }
public String actionPay(String tranId,String xtraParams, String tranSer,boolean onConf,Connection conn) throws RemoteException , ITMException public String actionPay(String tranId,String xtraParams, String tranSer,boolean onConf,Connection conn) throws RemoteException , ITMException
{ {
...@@ -67,36 +85,36 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -67,36 +85,36 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
int refCount=0; int refCount=0;
String sql=""; String sql="";
ITMDBAccessEJB itmDBAccessEJB=new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB=new ITMDBAccessEJB();
String tranType = "",loginUser = "",tranID = "",insertSql = "",remarks = "",lsRefNo="",chq2Str="",chq1Str=""; String tranType = "",loginUser = "",tranID = "",insertSql = "",remarks = "",lsRefNo="",chq2Str="",chq1Str="";
String termID = "",currCodeBc = "",exchRateBc = "",filtBankCodeAdd = "",filtBankCodeAddName = ""; String termID = "",currCodeBc = "",exchRateBc = "",filtBankCodeAdd = "",filtBankCodeAddName = "";
String acctCodeBal = "",cctrCodeBal = "",acctCodeBc = "",cctrCodeBc = "",acctCodeCf = ""; String acctCodeBal = "",cctrCodeBal = "",acctCodeBc = "",cctrCodeBc = "",acctCodeCf = "";
String acctCodeCfAp = "",cctrCodeCfAp = "",cctrCodeCf = "",updateSql = "",exchRateHdr = ""; String acctCodeCfAp = "",cctrCodeCfAp = "",cctrCodeCf = "",updateSql = "",exchRateHdr = "";
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
//ConnDriver connDriver = new ConnDriver(); //ConnDriver connDriver = new ConnDriver();
FinCommon finCommon = new FinCommon(); FinCommon finCommon = new FinCommon();
Timestamp tranDate=null,billDate=null,dueDate=null,refDate=null,effDate=null,ldDiscountDt=null,ldStartDate=null; Timestamp tranDate=null,billDate=null,dueDate=null,refDate=null,effDate=null,ldDiscountDt=null,ldStartDate=null;
String billNo="",currCode="",acctCode="",cctrCode="",siteCode="",finEntity="",sundryType="",bankCode="",userName="",sundryCode="",tranSerM="", String billNo="",currCode="",acctCode="",cctrCode="",siteCode="",finEntity="",sundryType="",bankCode="",userName="",sundryCode="",tranSerM="",
purcOrder="",pCrTerm="",acctCodeDisc="",cctrCodeDisc="",startFrom=""; purcOrder="",pCrTerm="",acctCodeDisc="",cctrCodeDisc="",startFrom="";
double exchRate=0.0d,totAmt=0.0d,advAmt=0.0d,holdAmt=0.0d,netPayable=0.0d,adjAmt=0.0d,lcDiscount=0.0d,lcDiscountAmt=0.0d,payAmt=0.0d,totAmount=0.0d; double exchRate=0.0d,totAmt=0.0d,advAmt=0.0d,holdAmt=0.0d,netPayable=0.0d,adjAmt=0.0d,lcDiscount=0.0d,lcDiscountAmt=0.0d,payAmt=0.0d,totAmount=0.0d;
double chq1=0,chq2=0; double chq1=0,chq2=0;
long llRefNo=0; long llRefNo=0;
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
try try
{ {
System.out.println("TranID["+tranId+"]"); System.out.println("TranID["+tranId+"]");
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("userId"+userId+"]"); System.out.println("userId"+userId+"]");
if("M-VOUC".equalsIgnoreCase(tranSer)) if("M-VOUC".equalsIgnoreCase(tranSer))
{ {
sql="Select confirmed,pay_mode,auto_pay from misc_voucher where tran_id= ?"; sql="Select confirmed,pay_mode,auto_pay from misc_voucher where tran_id= ?";
} }
else else
{ {
sql="Select confirmed,pay_mode,auto_pay from voucher where tran_id= ?"; sql="Select confirmed,pay_mode,auto_pay from voucher where tran_id= ?";
} }
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
...@@ -106,14 +124,26 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -106,14 +124,26 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
conf=rs.getString(1); conf=rs.getString(1);
payMode=rs.getString(2); payMode=rs.getString(2);
autoPay=rs.getString(3); autoPay=rs.getString(3);
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
sql="select count(1) from misc_paydet where tran_ser= ? and vouch_no= ?"; sql="select count(1) from misc_paydet where tran_ser= ? and vouch_no= ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranSer); pstmt.setString(1, tranSer);
...@@ -122,15 +152,26 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -122,15 +152,26 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
if(rs.next()) if(rs.next())
{ {
refCount=rs.getInt(1); refCount=rs.getInt(1);
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("conf["+conf+"] paymode["+payMode+"] refNo ["+refNo+"] refCount["+refCount+"]"); System.out.println("conf["+conf+"] paymode["+payMode+"] refNo ["+refNo+"] refCount["+refCount+"]");
//validation if not confirmed //validation if not confirmed
if(!"Y".equalsIgnoreCase(conf)) if(!"Y".equalsIgnoreCase(conf))
{ {
...@@ -151,36 +192,36 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -151,36 +192,36 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
errCode="VTINMODE"; errCode="VTINMODE";
errString = itmDBAccessEJB.getErrorString("",errCode, "", "", conn); errString = itmDBAccessEJB.getErrorString("",errCode, "", "", conn);
return errString; return errString;
} }
loginUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode"); loginUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termID = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId"); termID = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
tranType = finCommon.getFinparams("999999","TRAN_TYPE_AUTO_PAY",conn); tranType = finCommon.getFinparams("999999","TRAN_TYPE_AUTO_PAY",conn);
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if("NULLFOUND".equalsIgnoreCase(tranType)) if("NULLFOUND".equalsIgnoreCase(tranType))
tranType = "O"; tranType = "O";
//getting data from misc_payables //getting data from misc_payables
sql="SELECT MISC_PAYABLES.REF_NO,MISC_PAYABLES.TRAN_DATE,MISC_PAYABLES.REF_DATE,MISC_PAYABLES.BILL_NO," sql="SELECT MISC_PAYABLES.REF_NO,MISC_PAYABLES.TRAN_DATE,MISC_PAYABLES.REF_DATE,MISC_PAYABLES.BILL_NO,"
+ "MISC_PAYABLES.BILL_DATE,MISC_PAYABLES.CURR_CODE,MISC_PAYABLES.EXCH_RATE,MISC_PAYABLES.SUNDRY_CODE," + "MISC_PAYABLES.BILL_DATE,MISC_PAYABLES.CURR_CODE,MISC_PAYABLES.EXCH_RATE,MISC_PAYABLES.SUNDRY_CODE,"
+ "MISC_PAYABLES.ACCT_CODE,MISC_PAYABLES.CCTR_CODE,MISC_PAYABLES.DUE_DATE,MISC_PAYABLES.SITE_CODE," + "MISC_PAYABLES.ACCT_CODE,MISC_PAYABLES.CCTR_CODE,MISC_PAYABLES.DUE_DATE,MISC_PAYABLES.SITE_CODE,"
+ "MISC_PAYABLES.FIN_ENTITY,MISC_PAYABLES.TOT_AMT,MISC_PAYABLES.SUNDRY_TYPE,MISC_PAYABLES.BANK_CODE," + "MISC_PAYABLES.FIN_ENTITY,MISC_PAYABLES.TOT_AMT,MISC_PAYABLES.SUNDRY_TYPE,MISC_PAYABLES.BANK_CODE,"
+ "CASE WHEN MISC_PAYABLES.PAY_MODE IS NULL THEN '' ELSE MISC_PAYABLES.PAY_MODE END as PAY_MODE,MISC_PAYABLES.ADV_AMT,MISC_PAYABLES.TRAN_ID,MISC_PAYABLES.TRAN_SER,MISC_PAYABLES.ADJ_AMT," + "CASE WHEN MISC_PAYABLES.PAY_MODE IS NULL THEN '' ELSE MISC_PAYABLES.PAY_MODE END as PAY_MODE,MISC_PAYABLES.ADV_AMT,MISC_PAYABLES.TRAN_ID,MISC_PAYABLES.TRAN_SER,MISC_PAYABLES.ADJ_AMT,"
+ "MISC_PAYABLES.HOLD_AMT, fn_confirmed_by(misc_payables.tran_ser, misc_payables.ref_no) as username," + "MISC_PAYABLES.HOLD_AMT, fn_confirmed_by(misc_payables.tran_ser, misc_payables.ref_no) as username,"
+ "misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as net_payable " + "misc_payables.tot_amt - (case when misc_payables.adj_amt is null then 0 else misc_payables.adj_amt end) - (case when misc_payables.hold_amt is null then 0 else misc_payables.hold_amt end) as net_payable "
+ "FROM MISC_PAYABLES WHERE " + "FROM MISC_PAYABLES WHERE "
//+ "( misc_payables.sundry_type like '' ) AND" //+ "( misc_payables.sundry_type like '' ) AND"
//+ "( misc_payables.sundry_code like '' ) AND" //+ "( misc_payables.sundry_code like '' ) AND"
+ "( misc_payables.ref_no = ? ) " + "( misc_payables.ref_no = ? ) "
//+ "(misc_payables.pay_mode like 'C') AND" //+ "(misc_payables.pay_mode like 'C') AND"
//+ "misc_payables.entry_batch_no like ' '" //+ "misc_payables.entry_batch_no like ' '"
+ "ORDER BY MISC_PAYABLES.SUNDRY_TYPE ASC, " + "ORDER BY MISC_PAYABLES.SUNDRY_TYPE ASC, "
+ "MISC_PAYABLES.SUNDRY_CODE ASC," + "MISC_PAYABLES.SUNDRY_CODE ASC,"
+ "MISC_PAYABLES.REF_NO ASC "; + "MISC_PAYABLES.REF_NO ASC ";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranId ); pstmt.setString(1,tranId );
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
...@@ -210,151 +251,223 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -210,151 +251,223 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
netPayable=rs.getDouble("NET_PAYABLE"); netPayable=rs.getDouble("NET_PAYABLE");
sundryCode=rs.getString("sundry_code"); sundryCode=rs.getString("sundry_code");
tranSerM=rs.getString("tran_ser"); tranSerM=rs.getString("tran_ser");
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
Timestamp today = new java.sql.Timestamp(System.currentTimeMillis()); rs = null;
sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateFormat()); }
remarks = "Automatic Payment"; if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
Timestamp today = new java.sql.Timestamp(System.currentTimeMillis());
sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateFormat());
remarks = "Automatic Payment";
//bank details //bank details
sql = "select acct_code__bal, cctr_code__bal, acct_code__bc, cctr_code__bc,acct_code__cf, "+ sql = "select acct_code__bal, cctr_code__bal, acct_code__bc, cctr_code__bc,acct_code__cf, "+
"acct_code__cf_ap, cctr_code__cf, cctr_code__cf_ap from bank where bank_code = '"+bankCode+"'"; "acct_code__cf_ap, cctr_code__cf, cctr_code__cf_ap from bank where bank_code = '"+bankCode+"'";
System.out.println("SQL : "+sql); System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
acctCodeBal = rs.getString("acct_code__bal"); acctCodeBal = rs.getString("acct_code__bal");
cctrCodeBal = rs.getString("cctr_code__bal"); cctrCodeBal = rs.getString("cctr_code__bal");
acctCodeBc = rs.getString("acct_code__bc"); acctCodeBc = rs.getString("acct_code__bc");
cctrCodeBc = rs.getString("cctr_code__bc"); cctrCodeBc = rs.getString("cctr_code__bc");
acctCodeCf = rs.getString("acct_code__cf"); acctCodeCf = rs.getString("acct_code__cf");
acctCodeCfAp = rs.getString("acct_code__cf_ap"); acctCodeCfAp = rs.getString("acct_code__cf_ap");
cctrCodeCf = rs.getString("cctr_code__cf"); cctrCodeCf = rs.getString("cctr_code__cf");
cctrCodeCfAp = rs.getString("cctr_code__cf_ap"); cctrCodeCfAp = rs.getString("cctr_code__cf_ap");
} }
if(acctCodeCfAp == null || acctCodeCfAp.length() == 0) if(acctCodeCfAp == null || acctCodeCfAp.length() == 0)
{ {
acctCodeCfAp = acctCodeCf; acctCodeCfAp = acctCodeCf;
} }
if(cctrCodeCfAp == null || cctrCodeCfAp.length() == 0) if(cctrCodeCfAp == null || cctrCodeCfAp.length() == 0)
{ {
cctrCodeCfAp = cctrCodeCf; cctrCodeCfAp = cctrCodeCf;
} }
pstmt.close();
rs.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
//calculating discount for Voucher rs.close()*/
if("VOUCH".equalsIgnoreCase(tranSer)) if(rs != null)
{ {
sql="select purc_order,eff_date,bill_date from voucher where tran_id = ?"; rs.close();
pstmt = conn.prepareStatement(sql); rs = null;
pstmt.setString(1,refNo ); }
rs = pstmt.executeQuery(); if(pstmt!= null)
if(rs.next()) {
{ pstmt.close();
purcOrder=rs.getString("purc_order"); pstmt = null;
effDate=rs.getTimestamp("eff_date"); }
} //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
pstmt.close();
rs.close(); //calculating discount for Voucher
if("VOUCH".equalsIgnoreCase(tranSer))
sql="select cr_term from porder where purc_order = ?"; {
pstmt = conn.prepareStatement(sql); sql="select purc_order,eff_date,bill_date from voucher where tran_id = ?";
pstmt.setString(1,purcOrder ); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); pstmt.setString(1,refNo );
if(rs.next()) rs = pstmt.executeQuery();
{ if(rs.next())
pCrTerm=rs.getString("cr_term"); {
} purcOrder=rs.getString("purc_order");
pstmt.close(); effDate=rs.getTimestamp("eff_date");
rs.close(); }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
sql="select crtermfc.fin_chg,crterm.acct_code__disc,crterm.cctr_code__disc,crterm.start_from " rs.close()*/
+ "from crterm,crtermfc " if(rs != null)
+ "where crtermfc.cr_term = crterm.cr_term and crterm.cr_term = ? and trim(crtermfc.line_no) = '1'"; {
pstmt = conn.prepareStatement(sql); rs.close();
pstmt.setString(1,pCrTerm ); rs = null;
rs = pstmt.executeQuery(); }
if(rs.next()) if(pstmt!= null)
{ {
lcDiscount=rs.getDouble("fin_chg"); pstmt.close();
acctCodeDisc=rs.getString("acct_code__disc"); pstmt = null;
cctrCodeDisc=rs.getString("cctr_code__disc"); }
startFrom=rs.getString("start_from"); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
}
pstmt.close(); sql="select cr_term from porder where purc_order = ?";
rs.close(); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,purcOrder );
ldDiscountDt = calcDiscountDate(pCrTerm,(sdf.format(refDate)),(sdf.format(effDate)),(sdf.format(billDate)),conn); rs = pstmt.executeQuery();
System.out.println("Test"+ldDiscountDt); if(rs.next())
long liDateDiff=dayDiff(ldDiscountDt,today); {
pCrTerm=rs.getString("cr_term");
sql = "select fin_chg from crtermfc where ? between min_day and max_day and cr_term = ? and trim(line_no) = '1'"; }
pstmt = conn.prepareStatement(sql); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
pstmt.setLong(1, liDateDiff); /*pstmt.close();
pstmt.setString(2, pCrTerm); rs.close()*/
rs = pstmt.executeQuery(); if(rs != null)
{
if(rs.next()) rs.close();
{ rs = null;
lcDiscount=rs.getDouble(1); }
} if(pstmt!= null)
pstmt.close(); {
rs.close(); pstmt.close();
pstmt = null;
if(startFrom!=null && startFrom.trim().length()>0 ) }
{ //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
if("R".equalsIgnoreCase(startFrom))
{
ldStartDate=refDate; sql="select crtermfc.fin_chg,crterm.acct_code__disc,crterm.cctr_code__disc,crterm.start_from "
} + "from crterm,crtermfc "
else if("D".equalsIgnoreCase(startFrom) || "Q".equalsIgnoreCase(startFrom)) + "where crtermfc.cr_term = crterm.cr_term and crterm.cr_term = ? and trim(crtermfc.line_no) = '1'";
{ pstmt = conn.prepareStatement(sql);
ldStartDate=effDate; pstmt.setString(1,pCrTerm );
} rs = pstmt.executeQuery();
else if("B".equalsIgnoreCase(startFrom)) if(rs.next())
{ {
ldStartDate=billDate; lcDiscount=rs.getDouble("fin_chg");
} acctCodeDisc=rs.getString("acct_code__disc");
cctrCodeDisc=rs.getString("cctr_code__disc");
if((today.after(ldStartDate) || today.equals(ldStartDate)) && (today.before(ldDiscountDt) || today.equals(ldDiscountDt))) startFrom=rs.getString("start_from");
{ }
lcDiscountAmt=(payAmt*lcDiscount)/100; //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
} rs.close()*/
} if(rs != null)
{
} rs.close();
rs = null;
//calculating total amount }
totAmount = totAmt - lcDiscountAmt; if(pstmt!= null)
System.out.println("Pay Amt : "+payAmt + "Total Amt : "+totAmt); {
pstmt.close();
//09062007 (set currCode bc with Curr Code pstmt = null;
currCodeBc = currCode; }
String stanCode=getStanDraw(sundryType, sundryCode, conn); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
StringBuffer xmlBuff = new StringBuffer(); ldDiscountDt = calcDiscountDate(pCrTerm,(sdf.format(refDate)),(sdf.format(effDate)),(sdf.format(billDate)),conn);
System.out.println("Test"+ldDiscountDt);
long liDateDiff=dayDiff(ldDiscountDt,today);
sql = "select fin_chg from crtermfc where ? between min_day and max_day and cr_term = ? and trim(line_no) = '1'";
pstmt = conn.prepareStatement(sql);
pstmt.setLong(1, liDateDiff);
pstmt.setString(2, pCrTerm);
rs = pstmt.executeQuery();
if(rs.next())
{
lcDiscount=rs.getDouble(1);
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
rs.close()*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
if(startFrom!=null && startFrom.trim().length()>0 )
{
if("R".equalsIgnoreCase(startFrom))
{
ldStartDate=refDate;
}
else if("D".equalsIgnoreCase(startFrom) || "Q".equalsIgnoreCase(startFrom))
{
ldStartDate=effDate;
}
else if("B".equalsIgnoreCase(startFrom))
{
ldStartDate=billDate;
}
if((today.after(ldStartDate) || today.equals(ldStartDate)) && (today.before(ldDiscountDt) || today.equals(ldDiscountDt)))
{
lcDiscountAmt=(payAmt*lcDiscount)/100;
}
}
}
//calculating total amount
totAmount = totAmt - lcDiscountAmt;
System.out.println("Pay Amt : "+payAmt + "Total Amt : "+totAmt);
//09062007 (set currCode bc with Curr Code
currCodeBc = currCode;
String stanCode=getStanDraw(sundryType, sundryCode, conn);
StringBuffer xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n"); xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>"); xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>"); xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>"); xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>"); xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>"); xmlBuff.append("<Header0>");
if(onConf) if(onConf)
{ {
xmlBuff.append("<objName><![CDATA[").append("misc_pay_act").append("]]></objName>"); xmlBuff.append("<objName><![CDATA[").append("misc_pay_act").append("]]></objName>");
} }
else else
{ {
...@@ -372,10 +485,10 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -372,10 +485,10 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>"); xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>"); xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>"); xmlBuff.append("<description>").append("Header0 members").append("</description>");
if(onConf) if(onConf)
{ {
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"misc_pay_act\" objContext=\"1\">"); xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"misc_pay_act\" objContext=\"1\">");
} }
else else
{ {
...@@ -392,72 +505,96 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -392,72 +505,96 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
if("Q".equalsIgnoreCase(payMode) || "D".equalsIgnoreCase(payMode)) if("Q".equalsIgnoreCase(payMode) || "D".equalsIgnoreCase(payMode))
{ {
sql = "select chq1,chq2 from bank where bank_code=? and chq1 is not null and chq2 is not null"; sql = "select chq1,chq2 from bank where bank_code=? and chq1 is not null and chq2 is not null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
chq1Str=rs.getString("chq1"); chq1Str=rs.getString("chq1");
chq2Str=rs.getString("chq2"); chq2Str=rs.getString("chq2");
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
rs.close(); /*pstmt.close();
rs.close()*/
if ( (chq1Str!= null && chq1Str.trim().length()>0) &&(chq2Str!= null && chq2Str.trim().length()>0) ) if(rs != null)
{ {
chq1=Double.parseDouble(chq1Str); rs.close();
chq2=Double.parseDouble(chq2Str); rs = null;
sql = "select max( to_number(a.ref_no)) from ( select ref_no from banktran_log where bank_code = ? " }
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
if ( (chq1Str!= null && chq1Str.trim().length()>0) &&(chq2Str!= null && chq2Str.trim().length()>0) )
{
chq1=Double.parseDouble(chq1Str);
chq2=Double.parseDouble(chq2Str);
sql = "select max( to_number(a.ref_no)) from ( select ref_no from banktran_log where bank_code = ? "
+ " and ref_mode = 'Q' and ref_no is not null and ref_no <> ' ') a " + " and ref_mode = 'Q' and ref_no is not null and ref_no <> ' ') a "
+ " where a.ref_no >= ? and a.ref_no <= ? "; + " where a.ref_no >= ? and a.ref_no <= ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
pstmt.setString(2, chq1Str); pstmt.setString(2, chq1Str);
pstmt.setString(3, chq2Str); pstmt.setString(3, chq2Str);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
llRefNo=rs.getLong(1); llRefNo=rs.getLong(1);
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
rs.close(); /*pstmt.close();
if (llRefNo==0) rs.close()*/
{ if(rs != null)
{
lsRefNo=" "; rs.close();
rs = null;
} }
else if(pstmt!= null)
{ {
if(llRefNo==chq2) pstmt.close();
{ pstmt = null;
lsRefNo=" "; }
} //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
else if (llRefNo==0)
{ {
lsRefNo=Long.toString(llRefNo +1);
if (chq2Str.indexOf(0)==1 ) lsRefNo=" ";
{
lsRefNo="000000"+lsRefNo.substring(lsRefNo.length()-6); }
} else
} {
if(llRefNo==chq2)
{
} lsRefNo=" ";
}
} else
else {
{ lsRefNo=Long.toString(llRefNo +1);
lsRefNo=" "; if (chq2Str.indexOf(0)==1 )
} {
xmlBuff.append("<ref_no><![CDATA[" + lsRefNo + "]]></ref_no>"); lsRefNo="000000"+lsRefNo.substring(lsRefNo.length()-6);
}
}
}
}
else
{
lsRefNo=" ";
}
xmlBuff.append("<ref_no><![CDATA[" + lsRefNo + "]]></ref_no>");
} }
//added by Nandkumar Gadkari On 21/06/18------end-------------- //added by Nandkumar Gadkari On 21/06/18------end--------------
if(refDate!=null)// condition added by Nandkumar Gadkari On 21/06/18 if(refDate!=null)// condition added by Nandkumar Gadkari On 21/06/18
{ {
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>"); xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>");
} }
xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>"); xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>");
xmlBuff.append("<net_amt__bc><![CDATA[" + totAmount + "]]></net_amt__bc>"); xmlBuff.append("<net_amt__bc><![CDATA[" + totAmount + "]]></net_amt__bc>");
...@@ -478,20 +615,20 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -478,20 +615,20 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("<cctr_code__cf><![CDATA[" + cctrCodeCfAp + "]]></cctr_code__cf>"); xmlBuff.append("<cctr_code__cf><![CDATA[" + cctrCodeCfAp + "]]></cctr_code__cf>");
xmlBuff.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>"); xmlBuff.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>");
xmlBuff.append("</Detail1>"); xmlBuff.append("</Detail1>");
if(onConf) if(onConf)
{ {
xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay_act\" objContext=\"2\">"); xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay_act\" objContext=\"2\">");
} }
else else
{ {
xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay\" objContext=\"2\">"); xmlBuff.append("<Detail2 dbID=\"\" domID=\"1\" objName=\"misc_pay\" objContext=\"2\">");
} }
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_ser><![CDATA[" + tranSerM+ "]]></tran_ser>"); xmlBuff.append("<tran_ser><![CDATA[" + tranSerM+ "]]></tran_ser>");
if(refDate!=null)// condition added by Nandkumar Gadkari On 21/06/18 if(refDate!=null)// condition added by Nandkumar Gadkari On 21/06/18
{ {
xmlBuff.append("<vouch_date><![CDATA[" + sdf.format(refDate) + "]]></vouch_date>"); xmlBuff.append("<vouch_date><![CDATA[" + sdf.format(refDate) + "]]></vouch_date>");
} }
xmlBuff.append("<vouch_no><![CDATA[" + refNo + "]]></vouch_no>"); xmlBuff.append("<vouch_no><![CDATA[" + refNo + "]]></vouch_no>");
xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>"); xmlBuff.append("<net_amt><![CDATA[" + totAmount + "]]></net_amt>");
...@@ -510,23 +647,23 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -510,23 +647,23 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
xmlBuff.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>"); xmlBuff.append("<tax_amt><![CDATA[" + 0 + "]]></tax_amt>");
xmlBuff.append("<net_pay_amt><![CDATA[" + totAmount + "]]></net_pay_amt>"); xmlBuff.append("<net_pay_amt><![CDATA[" + totAmount + "]]></net_pay_amt>");
xmlBuff.append("</Detail2>"); xmlBuff.append("</Detail2>");
xmlBuff.append("</Header0>"); xmlBuff.append("</Header0>");
xmlBuff.append("</group0>"); xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>"); xmlBuff.append("</DocumentRoot>");
System.out.println("xmlBuff.toString() ["+xmlBuff.toString() + "]"); System.out.println("xmlBuff.toString() ["+xmlBuff.toString() + "]");
//calling process Request //calling process Request
retString=saveData(xtraParams, siteCode, xmlBuff.toString(),userId, conn); retString=saveData(xtraParams, siteCode, xmlBuff.toString(),userId, conn);
if( retString.indexOf("Success") != -1 || retString==null) if( retString.indexOf("Success") != -1 || retString==null)
{ {
conn.commit(); conn.commit();
return (itmDBAccessEJB.getErrorString("","VOUCHSUCC", "", "", conn)); return (itmDBAccessEJB.getErrorString("","VOUCHSUCC", "", "", conn));
} }
} }
catch(Exception e) catch(Exception e)
{ {
try try
{ {
...@@ -543,6 +680,13 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -543,6 +680,13 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
try try
{ {
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
if(rs != null)
{
rs.close();
rs = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
if(pstmt1 != null) if(pstmt1 != null)
{ {
pstmt1.close(); pstmt1.close();
...@@ -555,7 +699,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -555,7 +699,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
} }
if( conn != null && ! conn.isClosed() ) if( conn != null && ! conn.isClosed() )
{ {
/*conn.close(); /*conn.close();
conn = null;*/ conn = null;*/
} }
...@@ -569,9 +713,9 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -569,9 +713,9 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
} }
System.out.println("Returning Result ::"+retString); System.out.println("Returning Result ::"+retString);
return retString; return retString;
} }
private Timestamp getCurrdateAppFormat() private Timestamp getCurrdateAppFormat()
...@@ -605,45 +749,45 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -605,45 +749,45 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
} }
private String saveData(String xtraParams,String siteCode, String xmlString,String userId, Connection conn) throws ITMException private String saveData(String xtraParams,String siteCode, String xmlString,String userId, Connection conn) throws ITMException
{ {
System.out.println("saving data..........."); System.out.println("saving data...........");
InitialContext ctx = null; InitialContext ctx = null;
String retString = null; String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3 MasterStatefulLocal masterStateful = null; // for ejb3
ibase.utility.UserInfoBean userInfoBean=new UserInfoBean(); ibase.utility.UserInfoBean userInfoBean=new UserInfoBean();
try try
{ {
AppConnectParm appConnect = new AppConnectParm(); AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty()); ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local"); masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful); System.out.println("-----------masterStateful------- " + masterStateful);
String[] authencate = new String[2]; String[] authencate = new String[2];
authencate[0] = userId; authencate[0] = userId;
authencate[1] = ""; authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]"); System.out.println("xmlString to masterstateful [" + xmlString + "]");
userInfoBean.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode")); userInfoBean.setEmpCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
userInfoBean.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId")); userInfoBean.setRemoteHost(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
userInfoBean.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode")); userInfoBean.setSiteCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
userInfoBean.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode")); userInfoBean.setLoginCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
userInfoBean.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode")); userInfoBean.setEntityCode(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
retString=masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);//ocessRequest(userInfoBean,xmlString,true,conn); retString=masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);//ocessRequest(userInfoBean,xmlString,true,conn);
} catch (ITMException itme) } catch (ITMException itme)
{ {
System.out.println("ITMException :CreateDistOrder :saveData :==>"); System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme; throw itme;
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>"); System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e); throw new ITMException(e);
}
return retString;
} }
return retString;
}
private Timestamp calcDiscountDate(String crTerm, String vouchDate, String effDate, String billDate,Connection conn) throws ITMException private Timestamp calcDiscountDate(String crTerm, String vouchDate, String effDate, String billDate,Connection conn) throws ITMException
{ {
String discountDate="",sql="",lsStart="",lsMonth="",lsOverridediscdt=""; String discountDate="",sql="",lsStart="",lsMonth="",lsOverridediscdt="";
...@@ -687,7 +831,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -687,7 +831,7 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(ldTranDt); cal.setTime(ldTranDt);
liMonth = cal.get(Calendar.MONTH); liMonth = cal.get(Calendar.MONTH);
if(liMonth==12) if(liMonth==12)
{ {
liMonth=1; liMonth=1;
...@@ -717,10 +861,23 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -717,10 +861,23 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
sqlCount++; sqlCount++;
lsOverridediscdt=checkNull(rs.getString("override_discount_date")); lsOverridediscdt=checkNull(rs.getString("override_discount_date"));
} }
pstmt.close();
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
//System.out.println("@@@@@@@@1613 lsOverridediscdt["+lsOverridediscdt+"]");// //System.out.println("@@@@@@@@1613 lsOverridediscdt["+lsOverridediscdt+"]");//
if(sqlCount>0) if(sqlCount>0)
{ {
...@@ -745,10 +902,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -745,10 +902,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
lsOverridediscdt=checkNull(rs.getString("override_discount_date")); lsOverridediscdt=checkNull(rs.getString("override_discount_date"));
liDays=rs.getInt("max_day"); liDays=rs.getInt("max_day");
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
//System.out.println("@@@@@@@@1614 lsOverridediscdt["+lsOverridediscdt+"]"); //System.out.println("@@@@@@@@1614 lsOverridediscdt["+lsOverridediscdt+"]");
if(sqlCount>0) if(sqlCount>0)
{ {
...@@ -765,10 +934,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -765,10 +934,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
sqlCount++; sqlCount++;
liDays=rs.getInt("max_day"); liDays=rs.getInt("max_day");
} }
pstmt.close(); //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
if(sqlCount>0) if(sqlCount>0)
{ {
...@@ -799,22 +980,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -799,22 +980,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
long datediff=0; long datediff=0;
try try
{ {
/*SimpleDateFormat sdf1=new SimpleDateFormat("dd-MM-yyyy"); /*SimpleDateFormat sdf1=new SimpleDateFormat("dd-MM-yyyy");
String [] a1=(sdf1.format(discountDt)).split("-"); String [] a1=(sdf1.format(discountDt)).split("-");
String [] a2=(sdf1.format(paymentDt)).split("-"); String [] a2=(sdf1.format(paymentDt)).split("-");
System.out.println(Integer.parseInt(a2[2])+""+ Integer.parseInt(a2[1])+""+ Integer.parseInt(a2[0])); System.out.println(Integer.parseInt(a2[2])+""+ Integer.parseInt(a2[1])+""+ Integer.parseInt(a2[0]));
LocalDate discDate = LocalDate.of(Integer.parseInt(a1[2]), Integer.parseInt(a1[1]), Integer.parseInt(a1[0])); LocalDate discDate = LocalDate.of(Integer.parseInt(a1[2]), Integer.parseInt(a1[1]), Integer.parseInt(a1[0]));
LocalDate payDate = LocalDate.of(Integer.parseInt(a2[2]), Integer.parseInt(a2[1]), Integer.parseInt(a2[0])); LocalDate payDate = LocalDate.of(Integer.parseInt(a2[2]), Integer.parseInt(a2[1]), Integer.parseInt(a2[0]));
Period diff = Period.between(discDate, payDate); Period diff = Period.between(discDate, payDate);
difference=diff.getDays(); difference=diff.getDays();
System.out.printf("Difference is %d years, %d months and %d days old",diff.getYears(), diff.getMonths(), diff.getDays());*/ System.out.printf("Difference is %d years, %d months and %d days old",diff.getYears(), diff.getMonths(), diff.getDays());*/
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
Date discdt = sdf.parse(sdf.format(discountDt)); Date discdt = sdf.parse(sdf.format(discountDt));
Date mPayDate = sdf.parse(sdf.format(paymentDt)); Date mPayDate = sdf.parse(sdf.format(paymentDt));
System.out.println("mPayDate============" + mPayDate); System.out.println("mPayDate============" + mPayDate);
...@@ -827,10 +1008,10 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -827,10 +1008,10 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
throw new ITMException(e); throw new ITMException(e);
} }
return datediff; return datediff;
} }
public String getStanDraw(String sundryType, String sundryCode, Connection conn) public String getStanDraw(String sundryType, String sundryCode, Connection conn)
throws ITMException throws ITMException
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
...@@ -851,10 +1032,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -851,10 +1032,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type=E>>>>>>" + stanCode); System.out.println("StanCode from Sundry type=E>>>>>>" + stanCode);
} }
else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("S".equalsIgnoreCase(sundryType))) else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("S".equalsIgnoreCase(sundryType)))
...@@ -867,10 +1060,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -867,10 +1060,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type= S>>>>>>" + stanCode); System.out.println("StanCode from Sundry type= S>>>>>>" + stanCode);
} }
else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("C".equalsIgnoreCase(sundryType))) else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("C".equalsIgnoreCase(sundryType)))
...@@ -883,10 +1088,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -883,10 +1088,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type=C>>>>>>" + stanCode); System.out.println("StanCode from Sundry type=C>>>>>>" + stanCode);
} }
else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("P".equalsIgnoreCase(sundryType))) else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("P".equalsIgnoreCase(sundryType)))
...@@ -899,10 +1116,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -899,10 +1116,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
empCode = checkNull(rs.getString("emp_code")); empCode = checkNull(rs.getString("emp_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("empCode from Sundry type=P>>>>>>" + empCode); System.out.println("empCode from Sundry type=P>>>>>>" + empCode);
...@@ -916,10 +1145,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -916,10 +1145,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type=P>>>>>>" + stanCode); System.out.println("StanCode from Sundry type=P>>>>>>" + stanCode);
} }
...@@ -934,10 +1175,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -934,10 +1175,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type= T>>>>>>" + stanCode); System.out.println("StanCode from Sundry type= T>>>>>>" + stanCode);
} }
else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("X".equalsIgnoreCase(sundryType))) else if ((sundryType != null) && (sundryType.trim().length() > 0) && ("X".equalsIgnoreCase(sundryType)))
...@@ -950,10 +1203,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -950,10 +1203,22 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
stanCode = checkNull(rs.getString("stan_code")); stanCode = checkNull(rs.getString("stan_code"));
} }
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
/*pstmt.close();
pstmt=null;
rs.close(); rs.close();
pstmt.close(); rs=null;*/
pstmt = null; if(rs != null)
rs = null; {
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
System.out.println("StanCode from Sundry type= X>>>>>>" + stanCode); System.out.println("StanCode from Sundry type= X>>>>>>" + stanCode);
} }
...@@ -968,14 +1233,27 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -968,14 +1233,27 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
{ {
try try
{ {
if(pstmt!=null) //Modified by Anjali R. on[28/08/2018][Handle resource leak issue][Start]
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt!= null)
{
pstmt.close();
pstmt = null;
}
/*if(pstmt!=null)
{ {
pstmt.close();pstmt=null; pstmt.close();pstmt=null;
} }
if(rs!=null) if(rs!=null)
{ {
rs.close();rs=null; rs.close();rs=null;
} }*/
//Modified by Anjali R. on[28/08/2018][Handle resource leak issue][End]
} }
catch(Exception ex) catch(Exception ex)
{ {
...@@ -986,6 +1264,6 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V ...@@ -986,6 +1264,6 @@ public class VouchPayAct extends ActionHandlerEJB implements VouchPayActLocal, V
return stanCode; return stanCode;
} }
} }
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