Commit 71bfc693 authored by prane's avatar prane

Open Cursor Issue in PayablesOpenings

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@190826 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 52d28ae9
......@@ -58,7 +58,8 @@ public class PayablesOpeningConf extends ActionHandlerEJB implements PayablesO
}
private String confirmPayablesOpening(String tranID,String xtraParams)throws RemoteException,ITMException
{
Statement stmt = null,stmt1 = null,stmtcc = null,stmtUpd = null, stmt2 = null, stmt3 = null;
//Statement stmt = null,stmt1 = null,stmtcc = null,stmtUpd = null, stmt2 = null, stmt3 = null;
PreparedStatement pstmt1 = null,pstmt2 = null,pstmt3 = null;
PreparedStatement pstmt = null;
ResultSet rs = null,rscc = null,rsMast = null,rsDtl = null;
java.sql.Timestamp tranDate = null;
......@@ -102,8 +103,9 @@ conn = getConnection();
try
{
sqlHdr = "SELECT TRAN_DATE,SITE_CODE,FIN_ENTITY,CURR_CODE,TOT_AMT,ADJ_AMT,CONFIRMED, ACCT_PRD FROM PAYABLES_HDR WHERE TRAN_ID ='"+tranID.trim()+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sqlHdr);
//stmt = conn.createStatement();
pstmt2 = conn.prepareStatement(sqlHdr);
rs = pstmt2.executeQuery();
if (rs.next())
{
System.out.println("Entering into Header if...................");
......@@ -116,11 +118,16 @@ conn = getConnection();
confirmed = rs.getString("CONFIRMED");
acctPrd = rs.getString("ACCT_PRD"); //Gulzar 04-12-06
System.out.println("Tran_Id ::-"+tranID);
}
}
rs.close();
rs = null;
pstmt2.close();
pstmt2 = null;
}//try
catch(SQLException se)
{
System.out.println("SQLException []:[PayablesOpeningConfEJB][Excuting Query Failed]" + sqlHdr + se.getMessage());
se.printStackTrace();
}
catch(Exception ex)
{
......@@ -144,8 +151,9 @@ conn = getConnection();
+ "EXCH_RATE,DUE_DATE,TOT_AMT,ADJ_AMT,DIFF_AMOUNT,TRAN_DATE,REF_DATE,BILL_NO,"
+ "BILL_DATE,SUPP_BILL_AMT,PAY_MODE,ADV_AMT,PURC_ORDER,ENTRY_BATCH_NO "
+ "FROM PAYABLES_DTL WHERE TRAN_ID ='"+tranID+"'";
stmt = conn.createStatement();
rsDtl = stmt.executeQuery(sqlDtl);
//stmt = conn.createStatement();
pstmt2 = conn.prepareStatement(sqlDtl);
rsDtl = pstmt2.executeQuery();
while (rsDtl.next())
{
System.out.println("Entering into while...................");
......@@ -177,12 +185,17 @@ conn = getConnection();
+ "WHERE TRAN_SER = '"+tranSer.trim()+"' "
+ "AND REF_NO = '"+refNo.trim()+"' "
+ "AND SITE_CODE = '"+siteCode.trim() +"'";
stmt1 = conn.createStatement();
rsMast = stmt1.executeQuery(sql);
//stmt1 = conn.createStatement();
pstmt1 = conn.prepareStatement(sql);
rsMast = pstmt1.executeQuery();
if (rsMast.next())
{
cnt = rsMast.getInt("COUNT");
}
}
rsMast.close();
rsMast = null;
pstmt1.close();
pstmt1 = null;
}//try
catch(SQLException se)
{
......@@ -199,14 +212,19 @@ conn = getConnection();
sql = "SELECT TOT_AMT FROM MISC_PAYABLES "
+ "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);
rs = pstmt1.executeQuery();
if (rs.next())
{
totAmtOld = rs.getDouble("TOT_AMT");
}
rs.close();
rs = null;
pstmt1.close();
pstmt1 = null;
//rs.close();
amountDiff = totAmount - totAmtOld;
System.out.println("amountDiff = totAmount - totAmtOld : " + amountDiff);
if (totAmtOld < 0)
......@@ -229,7 +247,7 @@ conn = getConnection();
drAmtNew = 0d;
crAmtNew = totAmount;
}
stmt2.close();
//stmt2.close();
drAmount = drAmtNew - drAmtOld;
crAmount = crAmtNew - crAmtOld;
System.out.println("drAmount = drAmtNew - drAmtOld : " + drAmount);
......@@ -244,13 +262,17 @@ conn = getConnection();
String keyString = "",payblsTranID = "";
sql = "SELECT KEY_STRING FROM TRANSETUP WHERE TRAN_WINDOW = 'T_PAYABLES'";
stmt3 = conn.createStatement();
rs = stmt3.executeQuery(sql);
//stmt3 = conn.createStatement();
pstmt3 = conn.prepareStatement(sql);
rs = pstmt3.executeQuery();
if(rs.next())
{
keyString = rs.getString("KEY_STRING");
}
rs.close();
rs = null;
pstmt3.close();
pstmt3 = null;
String XMLString = "<?xml version=\"1.0\"?>\r\n<Root>\r\n<header>"+
"\r\n</header><Detail1>"+
"\r\n<site_code>"+siteCode+"</site_code>\r\n<tran_date>"+tranDate+"</tran_date></Detail1></Root>";
......@@ -303,10 +325,13 @@ conn = getConnection();
pstmt.setTimestamp(26,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("INSERT QUERY EXECUTED.................................");
}//try
catch(SQLException se)
{
se.printStackTrace();
System.out.println("SQLException [10][confirmReceivables][Excuting Query Failed]" + sqlIns + se.getMessage());
try
{
......@@ -333,7 +358,9 @@ conn = getConnection();
{
pstmt.close();
pstmt = null;
stmt3.close();
//stmt3.close();
pstmt3.close();
pstmt3 = null;
}
catch(Exception e)
......@@ -388,12 +415,15 @@ conn = getConnection();
pstmt.setDouble(23,suppBillAmt);
System.out.println("Setting Twenty Four Fields ..........24");
updInstr = pstmt.executeUpdate();
updInstr = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("QUERY !!!!!!!!!------"+ sqlUpd);
System.out.println("QUERY EXECUTED::UPDATE MASTER .........:: "+ updInstr);
}//try
catch(SQLException se)
{
se.printStackTrace();
System.out.println("SQLException [10][confirmPayablesOpening][Excuting Query Failed]" + sqlUpd + se.getMessage());
try
{
......@@ -485,16 +515,21 @@ conn = getConnection();
try
{
sql = "SELECT CONTACT_CODE FROM "+table+" WHERE "+column+" = '"+sundryCode.trim()+"'";
stmtcc = conn.createStatement();
rscc = stmtcc.executeQuery(sql);
//stmtcc = conn.createStatement();
pstmt3 = conn.prepareStatement(sql);
rscc = pstmt3.executeQuery();
if(rscc.next())
{
contactCode = rscc.getString(1);
}
rscc.close();
rscc = null;
pstmt3.close();
pstmt3 = null;
}
catch(SQLException se)
{
se.printStackTrace();
System.out.println("SQLException []:[PayablesOpeningConfEJB][Excuting Query Failed]" +sql+ se.getMessage());
}
sundrybalMap.put("contact_code",contactCode);
......@@ -550,16 +585,22 @@ conn = getConnection();
System.out.println("RETURN FROM ACCTBAL ENTRIES");
//conn.commit(); //Gulzar 04-12-06
}//while
rsDtl.close();
rsDtl = null;
pstmt2.close();
pstmt2 = null;
try
{
System.out.println("emp code:="+empCode);
update = "UPDATE PAYABLES_HDR SET CONFIRMED = 'Y', CONF_DATE = ? ,EMP_CODE__APRV = ? where TRAN_ID = ?";
System.out.println("Confirm update SQL ::"+ update);
//System.out.println("Confirm update SQL ::"+ update);
pstmt = conn.prepareStatement(update);
pstmt.setTimestamp(1,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(2,empCode);
pstmt.setString(3,tranID);
updCnt = pstmt.executeUpdate();
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("No of PAYABLES_HDR records updated ::*> "+updCnt);
if (updCnt == 1)
{
......@@ -642,10 +683,10 @@ conn = getConnection();
rsDtl.close();
rsDtl = null;
}
if (stmt != null)
if (pstmt != null)
{
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
}
if (conn != null)
{
......
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