*BF [ 1874419 ] JDBC Statement not close in a finally block

organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-19 07:17:32 +00:00
parent dde594363d
commit 17ad1bcfc2
1 changed files with 38 additions and 46 deletions

View File

@ -16,12 +16,25 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.acct; package org.compiere.acct;
import java.math.*; import java.math.BigDecimal;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.sql.SQLException;
import org.compiere.model.*; import java.util.ArrayList;
import org.compiere.util.*; import java.util.HashMap;
import java.util.logging.Level;
import org.compiere.model.MAccount;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MClientInfo;
import org.compiere.model.MCurrency;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MRequisitionLine;
import org.compiere.model.MTax;
import org.compiere.model.ProductCost;
import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Post Order Documents. * Post Order Documents.
@ -158,11 +171,12 @@ public class Doc_Order extends Doc
+ " AND o.C_Order_ID=?) " + " AND o.C_Order_ID=?) "
+ "ORDER BY rl.C_OrderLine_ID"; + "ORDER BY rl.C_OrderLine_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, order.getC_Order_ID()); pstmt.setInt (1, order.getC_Order_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MRequisitionLine line = new MRequisitionLine (getCtx(), rs, null); MRequisitionLine line = new MRequisitionLine (getCtx(), rs, null);
@ -184,23 +198,15 @@ public class Doc_Order extends Doc
docLine.setAmount (LineNetAmt); // DR docLine.setAmount (LineNetAmt); // DR
list.add (docLine); list.add (docLine);
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
// Return Array // Return Array
@ -500,12 +506,13 @@ public class Doc_Order extends Doc
+ "WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID" + "WHERE po.C_OrderLine_ID=ol.C_OrderLine_ID"
+ " AND po.C_InvoiceLine_ID=?)"; + " AND po.C_InvoiceLine_ID=?)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, C_InvoiceLine_ID); pstmt.setInt (1, C_InvoiceLine_ID);
pstmt.setInt (2, C_InvoiceLine_ID); pstmt.setInt (2, C_InvoiceLine_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
if (maxQty.signum() == 0) if (maxQty.signum() == 0)
@ -553,23 +560,15 @@ public class Doc_Order extends Doc
docLine.setAmount (LineNetAmt, PriceList, Qty); docLine.setAmount (LineNetAmt, PriceList, Qty);
list.add(docLine); list.add(docLine);
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
// Return Array // Return Array
@ -648,11 +647,12 @@ public class Doc_Order extends Doc
+ "WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID" + "WHERE il.C_OrderLine_ID=ol.C_OrderLine_ID"
+ " AND il.M_InOutLine_ID=?)"; + " AND il.M_InOutLine_ID=?)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, M_InOutLine_ID); pstmt.setInt (1, M_InOutLine_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
if (maxQty.signum() == 0) if (maxQty.signum() == 0)
@ -700,23 +700,15 @@ public class Doc_Order extends Doc
docLine.setAmount (LineNetAmt, PriceList, Qty); docLine.setAmount (LineNetAmt, PriceList, Qty);
list.add(docLine); list.add(docLine);
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
// Return Array // Return Array