Commit 49574f32 authored by dpawar's avatar dpawar

handle connection


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96267 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e7b62b28
...@@ -501,8 +501,7 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa ...@@ -501,8 +501,7 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa
//postSave() added by kunal on 11/07/13 FOR cross update //postSave() added by kunal on 11/07/13 FOR cross update
public String postSave(String winName,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException public String postSave(String winName,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException
{ {
System.out.println("--------------my postSave called.............................."+tranId);
String sql = "",saleOrder = "",lotsl="",siteCode=""; String sql = "",saleOrder = "",lotsl="",siteCode="";
int lineNo = 0; int lineNo = 0;
double grossWeight = 0,tareWeight = 0,netWeight = 0,noAart = 0,offinvAmt = 0,billbackAmt = 0,quantity=0 ; double grossWeight = 0,tareWeight = 0,netWeight = 0,noAart = 0,offinvAmt = 0,billbackAmt = 0,quantity=0 ;
...@@ -510,20 +509,18 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa ...@@ -510,20 +509,18 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa
//GenericUtility genericUtility = GenericUtility.getInstance(); //GenericUtility genericUtility = GenericUtility.getInstance();
PreparedStatement pstmt = null,pstmt1 = null; PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null; ResultSet rs = null,rs1 = null;
boolean isError=true;
//System.out.println("tranId="+tranId+" xtraParams="+xtraParams); //System.out.println("tranId="+tranId+" xtraParams="+xtraParams);
try try
{ {
if(conn!=null){
System.out.println("Connection not null.................1234");
}
conn=null; conn=null;
System.out.println("connection is null.............."); if(conn == null){
ConnDriver connDriver = new ConnDriver(); System.out.println("connection is null..............");
conn = connDriver.getConnectDB("DriverITM"); ConnDriver connDriver = new ConnDriver();
conn.setAutoCommit(false); conn = connDriver.getConnectDB("DriverITM");
connDriver=null; conn.setAutoCommit(false);
connDriver=null;
}
sql = " select sord_no,line_no__sord ,quantity__stduom,rate__stduom ,disc_schem_offinv_amt,tax_amt from despatchdet where desp_id = ? "; sql = " select sord_no,line_no__sord ,quantity__stduom,rate__stduom ,disc_schem_offinv_amt,tax_amt from despatchdet where desp_id = ? ";
...@@ -612,37 +609,46 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa ...@@ -612,37 +609,46 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa
lotsl = rs.getString(1) == null ? "":rs.getString(1); lotsl = rs.getString(1) == null ? "":rs.getString(1);
sql = "select quantity,site_code from despatchdet where desp_id = ? and lot_sl = ?"; sql = "select quantity,site_code from despatchdet where desp_id = ? and lot_sl = ?";
pstmt= conn.prepareStatement(sql); pstmt1= conn.prepareStatement(sql);
//System.out.println("Second sql ["+sql + "]"); //System.out.println("Second sql ["+sql + "]");
pstmt.setString( 1, tranId ); pstmt1.setString( 1, tranId );
pstmt.setString( 2, lotsl ); pstmt1.setString( 2, lotsl );
rs = pstmt.executeQuery(); rs1 = pstmt1.executeQuery();
if(rs.next()) if(rs1.next())
{ {
quantity = rs.getDouble("quantity"); quantity = rs1.getDouble("quantity");
siteCode = rs.getString("site_code") == null ? "":rs.getString("site_code"); siteCode = rs1.getString("site_code") == null ? "":rs1.getString("site_code");
}
if(rs1!=null){
rs1.close();
rs1 = null;
}
if(pstmt1 !=null){
pstmt1.close();
pstmt1 = null;
} }
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "UPDATE stock SET ALLOC_QTY = ? WHERE site_code = ? AND LOT_SL = ? AND QUANTITY > 0"; sql = "UPDATE stock SET ALLOC_QTY = ? WHERE site_code = ? AND LOT_SL = ? AND QUANTITY > 0";
pstmt= conn.prepareStatement(sql); pstmt1= conn.prepareStatement(sql);
//System.out.println("First sql ["+ sql + "] tranId [" + tranId + "]"); //System.out.println("First sql ["+ sql + "] tranId [" + tranId + "]");
pstmt.setDouble( 1, quantity); pstmt1.setDouble( 1, quantity);
pstmt.setString( 2, siteCode); pstmt1.setString( 2, siteCode);
pstmt.setString( 3, lotsl); pstmt1.setString( 3, lotsl);
pstmt.executeUpdate(); pstmt1.executeUpdate();
conn.commit(); if(pstmt1 !=null){
pstmt.close(); pstmt1.close();
pstmt = null; pstmt1 = null;
}
} }
if(rs!=null){
rs.close(); rs.close();
rs = null; rs = null;
}
if(pstmt!=null){
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
}
//new add end //new add end
...@@ -651,14 +657,40 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa ...@@ -651,14 +657,40 @@ public class DespatchPos extends ValidatorEJB implements DespatchPosLocal, Despa
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
try{
isError=false;
conn.rollback();
}
catch(Exception e1){
e1.printStackTrace();
}
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
System.out.println("Inside Finally isError---->>["+isError+"]");
try try
{ {
if(pstmt != null)pstmt.close(); if(rs!=null){
rs.close();
rs = null;
}
if(pstmt!=null){
pstmt.close();
pstmt = null; pstmt = null;
}
if(pstmt1 !=null){
pstmt1.close();
pstmt1 = null;
}
if(isError){
conn.commit();
}
if(conn !=null){
conn.close();
conn=null;
}
}catch(Exception d) }catch(Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
......
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