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