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
private String confirmReceivables(String tranID, String xtraParams) throws RemoteException,ITMException
{
String retString = "";
Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null;
PreparedStatement pstmt = null;
//Statement stmt = null, stmt1 = null, stmt2 = null, stmt3 = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null,pstmt3 = null;
ResultSet rs = null;
ResultSet rsDtl = null;
ResultSet rsMst = null;
......@@ -160,8 +160,9 @@ conn = getConnection();
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
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlHdr);
//stmt = conn.createStatement();
pstmt = conn.prepareStatement(sqlHdr);
rs = pstmt.executeQuery();
if (rs.next())
{
tranDate = rs.getTimestamp("TRAN_DATE");
......@@ -175,6 +176,10 @@ conn = getConnection();
acctPrd = rs.getString("ACCT_PRD"); //Gulzar 30/11/6
refType = rs.getString("TRAN_TYPE"); //Gulzar 02-12-06
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
catch(SQLException se)
{
......@@ -194,9 +199,10 @@ conn = getConnection();
{
try
{
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
catch(Exception e)
{
......@@ -220,9 +226,9 @@ conn = getConnection();
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+"'";
stmt = conn.createStatement();
rsDtl = stmt.executeQuery(sqlDtl);
//stmt = conn.createStatement();
pstmt3 = conn.prepareStatement(sqlDtl);
rsDtl = pstmt3.executeQuery();
while (rsDtl.next())
......@@ -261,12 +267,17 @@ conn = getConnection();
{
sql = "SELECT COUNT(1) AS COUNT FROM RECEIVABLES "
+ "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'";
stmt1 = conn.createStatement();
rsMst = stmt1.executeQuery(sql);
//stmt1 = conn.createStatement();
pstmt1 = conn.prepareStatement(sql);
rsMst = pstmt1.executeQuery();
if (rsMst.next())
{
cnt = rsMst.getInt("COUNT");
}
pstmt1.close();
pstmt1 = null;
rsMst.close();
rsMst = null;
}
catch(SQLException se)
{
......@@ -288,8 +299,8 @@ conn = getConnection();
{
rsMst.close();
rsMst = null;
stmt1.close();
stmt1 = null;
pstmt1.close();
pstmt1 = null;
}
catch(Exception e)
{
......@@ -304,14 +315,19 @@ conn = getConnection();
sql = "SELECT TOT_AMT FROM RECEIVABLES "
+ "WHERE TRAN_SER = '"+ tranSer +"' AND REF_NO = '"+ refNo +"' AND SITE_CODE = '"+ siteCode +"'";
stmt2 = conn.createStatement();
rs = stmt2.executeQuery(sql);
//stmt2 = conn.createStatement();
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;
System.out.println("diffAmt = totAmt - totAmtOld : " + diffAmt);
if (totAmtOld < 0)
......@@ -334,7 +350,7 @@ conn = getConnection();
crAmtNew = 0d;
drAmtNew = totAmt;
}
stmt2.close();
//stmt2.close();
drAmt = drAmtNew - drAmtOld;
crAmt = crAmtNew - crAmtOld;
System.out.println("drAmt = drAmtNew - drAmtOld : " + drAmt);
......@@ -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
stmt3 = conn.createStatement();
rs = stmt3.executeQuery(sql);
if(rs.next())
//stmt3 = conn.createStatement();
pstmt1 = conn.prepareStatement(sql);
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>"+
"\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>";
......@@ -422,7 +442,9 @@ conn = getConnection();
pstmt.setString(40,refSerOrg);
pstmt.setString(41,saleOrder);
pstmt.setString(42,"1");
pstmt.executeUpdate();
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Insert Query Executed : FOR 000000 IN RECEIVABLES MASTER");
}
catch(SQLException se)
......@@ -451,10 +473,11 @@ conn = getConnection();
{
try
{
pstmt.close();
pstmt = null;
stmt3.close();
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
......@@ -528,6 +551,7 @@ conn = getConnection();
pstmt.executeUpdate();
System.out.println("Upadte Query Executed : 000000 IN RECEIVABLES MASTER");
pstmt.close();
pstmt = null;
}
catch(SQLException se)
{
......@@ -669,6 +693,10 @@ conn = getConnection();
//conn.commit(); //Jiten 27/07/06 - not required
}
rsDtl.close();
rsDtl = null;
pstmt3.close();
pstmt3 = null;
try
{
String sqlUpdateHdr = "UPDATE RECEIVABLES_HDR SET CONFIRMED = 'Y', CONF_DATE = ? ,EMP_CODE__APRV = ? WHERE TRAN_ID = ?";
......@@ -677,7 +705,9 @@ conn = getConnection();
pstmt.setTimestamp(1,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(2,empCode);
pstmt.setString(3,tranID);
int conf = pstmt.executeUpdate();
int conf = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if(conf == 1)
{
System.out.println("RECEIVABLES_HDR Updated...(Confirmed)" + userId);
......@@ -689,6 +719,7 @@ conn = getConnection();
{
System.out.println("RECEIVABLES_HDR Not Updated...(Not Confirmed)");
}
}
catch(SQLException se)
{
......@@ -747,10 +778,10 @@ conn = getConnection();
{
try
{
if (stmt != null)
if (pstmt != null)
{
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
}
if (rsDtl != null)
{
......@@ -785,31 +816,31 @@ conn = getConnection();
{
try
{
if (stmt1 != null)
if (pstmt1 != null)
{
stmt1.close();
stmt1 = null;
pstmt1.close();
pstmt1 = null;
}
if (stmt2 != null)
if (pstmt2 != null)
{
stmt2.close();
stmt2 = null;
pstmt2.close();
pstmt2 = null;
}
if (stmt3 != null)
if (pstmt3 != null)
{
stmt3.close();
stmt3 = null;
}
if (stmt != null)
{
stmt.close();
stmt = null;
pstmt3.close();
pstmt3 = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
/*if (pstmt != null)
{
pstmt.close();
pstmt = null;
}*/
if (rsDtl != null)
{
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