Commit 57d942a2 authored by prane's avatar prane

Open Cursor Issue in Receivables Opening

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@190793 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 88c1413d
...@@ -66,8 +66,8 @@ public class ReceivablesOpeningConf extends ActionHandlerEJB implements Receivab ...@@ -66,8 +66,8 @@ public class ReceivablesOpeningConf extends ActionHandlerEJB implements Receivab
private String confirmReceivables(String tranID, String xtraParams) throws RemoteException,ITMException private String confirmReceivables(String tranID, String xtraParams) throws RemoteException,ITMException
{ {
String retString = ""; String retString = "";
Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null; //Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null;
ResultSet rs = null; ResultSet rs = null;
ResultSet rsDtl = null; ResultSet rsDtl = null;
ResultSet rsMst = null; ResultSet rsMst = null;
...@@ -160,8 +160,9 @@ conn = getConnection(); ...@@ -160,8 +160,9 @@ conn = getConnection();
try try
{ {
sqlHdr = "SELECT TRAN_DATE, SITE_CODE, FIN_ENTITY, CURR_CODE, TOT_AMT, ADJ_AMT, EMP_CODE__APRV, CONFIRMED, ACCT_PRD, TRAN_TYPE FROM RECEIVABLES_HDR WHERE TRAN_ID ='"+ tranID +"'"; //ACCT_PRD and TRAN_TYPE ADDED GULZAR 02-12-06 sqlHdr = "SELECT TRAN_DATE, SITE_CODE, FIN_ENTITY, CURR_CODE, TOT_AMT, ADJ_AMT, EMP_CODE__APRV, CONFIRMED, ACCT_PRD, TRAN_TYPE FROM RECEIVABLES_HDR WHERE TRAN_ID ='"+ tranID +"'"; //ACCT_PRD and TRAN_TYPE ADDED GULZAR 02-12-06
stmt = conn.createStatement(); //stmt = conn.createStatement();
rs = stmt.executeQuery(sqlHdr); pstmt = conn.prepareStatement(sqlHdr);
rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
tranDate = rs.getTimestamp("TRAN_DATE"); tranDate = rs.getTimestamp("TRAN_DATE");
...@@ -175,6 +176,10 @@ conn = getConnection(); ...@@ -175,6 +176,10 @@ conn = getConnection();
acctPrd = rs.getString("ACCT_PRD"); //Gulzar 30/11/6 acctPrd = rs.getString("ACCT_PRD"); //Gulzar 30/11/6
refType = rs.getString("TRAN_TYPE"); //Gulzar 02-12-06 refType = rs.getString("TRAN_TYPE"); //Gulzar 02-12-06
} }
pstmt.close();
pstmt = null;
rs.close();
rs = null;
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -194,9 +199,10 @@ conn = getConnection(); ...@@ -194,9 +199,10 @@ conn = getConnection();
{ {
try try
{ {
stmt.close(); pstmt.close();
stmt = null; pstmt = null;
rs.close(); rs.close();
rs = null;
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -220,9 +226,9 @@ conn = getConnection(); ...@@ -220,9 +226,9 @@ conn = getConnection();
try try
{ {
sqlDtl = "SELECT TRAN_SER, REF_NO, REF_DATE, TRAN_DATE, CUST_CODE, ACCT_CODE, CCTR_CODE, CURR_CODE, EXCH_RATE, TOT_AMT, ADJ_AMT, CR_TERM, DUE_DATE, REAS_CODE, ITEM_SER, SALES_PERS, SALES_PERS__1, SALES_PERS__2, CONTACT_CODE, FIN_SCHEME, SALE_ORDER, DIFF_AMT FROM RECEIVABLES_DTL WHERE TRAN_ID ='"+tranID+"'"; sqlDtl = "SELECT TRAN_SER, REF_NO, REF_DATE, TRAN_DATE, CUST_CODE, ACCT_CODE, CCTR_CODE, CURR_CODE, EXCH_RATE, TOT_AMT, ADJ_AMT, CR_TERM, DUE_DATE, REAS_CODE, ITEM_SER, SALES_PERS, SALES_PERS__1, SALES_PERS__2, CONTACT_CODE, FIN_SCHEME, SALE_ORDER, DIFF_AMT FROM RECEIVABLES_DTL WHERE TRAN_ID ='"+tranID+"'";
stmt = conn.createStatement(); //stmt = conn.createStatement();
pstmt3 = conn.prepareStatement(sqlDtl);
rsDtl = stmt.executeQuery(sqlDtl); rsDtl = pstmt3.executeQuery();
while (rsDtl.next()) while (rsDtl.next())
...@@ -261,12 +267,17 @@ conn = getConnection(); ...@@ -261,12 +267,17 @@ conn = getConnection();
{ {
sql = "SELECT COUNT(1) AS COUNT FROM RECEIVABLES " sql = "SELECT COUNT(1) AS COUNT FROM RECEIVABLES "
+ "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'"; + "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'";
stmt1 = conn.createStatement(); //stmt1 = conn.createStatement();
rsMst = stmt1.executeQuery(sql); pstmt1 = conn.prepareStatement(sql);
rsMst = pstmt1.executeQuery();
if (rsMst.next()) if (rsMst.next())
{ {
cnt = rsMst.getInt("COUNT"); cnt = rsMst.getInt("COUNT");
} }
pstmt1.close();
pstmt1 = null;
rsMst.close();
rsMst = null;
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -288,8 +299,8 @@ conn = getConnection(); ...@@ -288,8 +299,8 @@ conn = getConnection();
{ {
rsMst.close(); rsMst.close();
rsMst = null; rsMst = null;
stmt1.close(); pstmt1.close();
stmt1 = null; pstmt1 = null;
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -304,14 +315,19 @@ conn = getConnection(); ...@@ -304,14 +315,19 @@ conn = getConnection();
sql = "SELECT TOT_AMT FROM RECEIVABLES " sql = "SELECT TOT_AMT FROM RECEIVABLES "
+ "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'"; + "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'";
stmt2 = conn.createStatement(); //stmt2 = conn.createStatement();
rs = stmt2.executeQuery(sql); pstmt1 = conn.prepareStatement(sql);
rsMst = pstmt1.executeQuery();
if (rs.next()) if (rsMst.next())
{ {
totAmtOld = rs.getDouble("TOT_AMT"); totAmtOld = rsMst.getDouble("TOT_AMT");
} }
rs.close(); //rs.close();
pstmt1.close();
pstmt1 = null;
rsMst.close();
rsMst = null;
diffAmt = totAmt - totAmtOld; diffAmt = totAmt - totAmtOld;
System.out.println("diffAmt = totAmt - totAmtOld : " + diffAmt); System.out.println("diffAmt = totAmt - totAmtOld : " + diffAmt);
if (totAmtOld < 0) if (totAmtOld < 0)
...@@ -334,7 +350,7 @@ conn = getConnection(); ...@@ -334,7 +350,7 @@ conn = getConnection();
crAmtNew = 0d; crAmtNew = 0d;
drAmtNew = totAmt; drAmtNew = totAmt;
} }
stmt2.close(); //stmt2.close();
drAmt = drAmtNew - drAmtOld; drAmt = drAmtNew - drAmtOld;
crAmt = crAmtNew - crAmtOld; crAmt = crAmtNew - crAmtOld;
System.out.println("drAmt = drAmtNew - drAmtOld : " + drAmt); System.out.println("drAmt = drAmtNew - drAmtOld : " + drAmt);
...@@ -349,13 +365,17 @@ conn = getConnection(); ...@@ -349,13 +365,17 @@ conn = getConnection();
//sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 'T_RCVABLES'"; //Gulzar 29/08/06 //sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 'T_RCVABLES'"; //Gulzar 29/08/06
sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 't_rcvables'"; //Gulzar 29/08/06 sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 't_rcvables'"; //Gulzar 29/08/06
stmt3 = conn.createStatement(); //stmt3 = conn.createStatement();
rs = stmt3.executeQuery(sql); pstmt1 = conn.prepareStatement(sql);
if(rs.next()) rsMst = pstmt1.executeQuery();
if(rsMst.next())
{ {
keyString = rs.getString("KEY_STRING"); keyString = rsMst.getString("KEY_STRING");
} }
rs.close(); rsMst.close();
rsMst = null;
pstmt1.close();
pstmt1 = null;
String XMLString = "<?xml version=\"1.0\"?>\r\n<Root>\r\n<header>"+ String XMLString = "<?xml version=\"1.0\"?>\r\n<Root>\r\n<header>"+
"\r\n</header><Detail1><item_ser>"+itemSer+"</item_ser>"+ "\r\n</header><Detail1><item_ser>"+itemSer+"</item_ser>"+
"\r\n<site_code>"+siteCode+"</site_code>\r\n<tran_date>"+tranDate+"</tran_date></Detail1></Root>"; "\r\n<site_code>"+siteCode+"</site_code>\r\n<tran_date>"+tranDate+"</tran_date></Detail1></Root>";
...@@ -422,7 +442,9 @@ conn = getConnection(); ...@@ -422,7 +442,9 @@ conn = getConnection();
pstmt.setString(40,refSerOrg); pstmt.setString(40,refSerOrg);
pstmt.setString(41,saleOrder); pstmt.setString(41,saleOrder);
pstmt.setString(42,"1"); pstmt.setString(42,"1");
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Insert Query Executed : FOR 000000 IN RECEIVABLES MASTER"); System.out.println("Insert Query Executed : FOR 000000 IN RECEIVABLES MASTER");
} }
catch(SQLException se) catch(SQLException se)
...@@ -451,10 +473,11 @@ conn = getConnection(); ...@@ -451,10 +473,11 @@ conn = getConnection();
{ {
try try
{ {
pstmt.close(); if (pstmt != null)
pstmt = null; {
stmt3.close(); pstmt.close();
pstmt = null;
}
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -528,6 +551,7 @@ conn = getConnection(); ...@@ -528,6 +551,7 @@ conn = getConnection();
pstmt.executeUpdate(); pstmt.executeUpdate();
System.out.println("Upadte Query Executed : 000000 IN RECEIVABLES MASTER"); System.out.println("Upadte Query Executed : 000000 IN RECEIVABLES MASTER");
pstmt.close(); pstmt.close();
pstmt = null;
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -669,6 +693,10 @@ conn = getConnection(); ...@@ -669,6 +693,10 @@ conn = getConnection();
//conn.commit(); //Jiten 27/07/06 - not required //conn.commit(); //Jiten 27/07/06 - not required
} }
rsDtl.close();
rsDtl = null;
pstmt3.close();
pstmt3 = null;
try try
{ {
String sqlUpdateHdr = "UPDATE RECEIVABLES_HDR SET CONFIRMED = 'Y', CONF_DATE = ? ,EMP_CODE__APRV = ? WHERE TRAN_ID = ?"; String sqlUpdateHdr = "UPDATE RECEIVABLES_HDR SET CONFIRMED = 'Y', CONF_DATE = ? ,EMP_CODE__APRV = ? WHERE TRAN_ID = ?";
...@@ -677,7 +705,9 @@ conn = getConnection(); ...@@ -677,7 +705,9 @@ conn = getConnection();
pstmt.setTimestamp(1,new java.sql.Timestamp(System.currentTimeMillis())); pstmt.setTimestamp(1,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(2,empCode); pstmt.setString(2,empCode);
pstmt.setString(3,tranID); pstmt.setString(3,tranID);
int conf = pstmt.executeUpdate(); int conf = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if(conf == 1) if(conf == 1)
{ {
System.out.println("RECEIVABLES_HDR Updated...(Confirmed)" + userId); System.out.println("RECEIVABLES_HDR Updated...(Confirmed)" + userId);
...@@ -689,6 +719,7 @@ conn = getConnection(); ...@@ -689,6 +719,7 @@ conn = getConnection();
{ {
System.out.println("RECEIVABLES_HDR Not Updated...(Not Confirmed)"); System.out.println("RECEIVABLES_HDR Not Updated...(Not Confirmed)");
} }
} }
catch(SQLException se) catch(SQLException se)
{ {
...@@ -747,10 +778,10 @@ conn = getConnection(); ...@@ -747,10 +778,10 @@ conn = getConnection();
{ {
try try
{ {
if (stmt != null) if (pstmt != null)
{ {
stmt.close(); pstmt.close();
stmt = null; pstmt = null;
} }
if (rsDtl != null) if (rsDtl != null)
{ {
...@@ -785,31 +816,31 @@ conn = getConnection(); ...@@ -785,31 +816,31 @@ conn = getConnection();
{ {
try try
{ {
if (stmt1 != null) if (pstmt1 != null)
{ {
stmt1.close(); pstmt1.close();
stmt1 = null; pstmt1 = null;
} }
if (stmt2 != null) if (pstmt2 != null)
{ {
stmt2.close(); pstmt2.close();
stmt2 = null; pstmt2 = null;
} }
if (stmt3 != null) if (pstmt3 != null)
{ {
stmt3.close(); pstmt3.close();
stmt3 = null; pstmt3 = null;
}
if (stmt != null)
{
stmt.close();
stmt = null;
} }
if (pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
/*if (pstmt != null)
{
pstmt.close();
pstmt = null;
}*/
if (rsDtl != null) if (rsDtl != null)
{ {
rsDtl.close(); rsDtl.close();
......
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