IDEMPIERE-568 Review proper closing of JDBC statements and resultsets

This commit is contained in:
Carlos Ruiz 2013-02-19 16:16:17 -05:00
parent 9b0c13b9f5
commit cb10e71ad0
1 changed files with 36 additions and 24 deletions

View File

@ -2698,15 +2698,22 @@ public class MOrder extends X_C_Order implements DocAction
List<MOrderLine> result = new Vector<MOrderLine>();
Properties ctx = Env.getCtx();
MOrderLine line;
PreparedStatement ps = conn.prepareStatement(OrderLinesToAllocate);
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(OrderLinesToAllocate);
ps.setInt(1, productId);
ResultSet rs = ps.executeQuery();
rs = ps.executeQuery();
while(rs.next()) {
line = new MOrderLine(ctx, rs, trxName);
result.add(line);
}
rs.close();
ps.close();
} catch (SQLException e) {
throw e;
} finally {
DB.close(rs, ps);
rs = null; ps = null;
}
return(result);
}
@ -2735,12 +2742,13 @@ public class MOrder extends X_C_Order implements DocAction
"(QtyOrdered-QtyDelivered)>0 AND (QtyOrdered-QtyDelivered)>C_OrderLine.QtyAllocated)" +
"group by M_Product_ID " +
"order by M_Product_ID";
PreparedStatement ps = conn.prepareStatement(query1);
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(query1);
ps.setInt(1, WarehouseID);
ps.setInt(2, WarehouseID);
ResultSet rs = ps.executeQuery();
rs = ps.executeQuery();
while(rs.next()) {
si = new StockInfo();
si.productId = rs.getInt(1);
@ -2750,8 +2758,12 @@ public class MOrder extends X_C_Order implements DocAction
si.qtyAllocated = rs.getBigDecimal(4);
result.add(si);
}
rs.close();
ps.close();
} catch (SQLException e) {
throw e;
} finally {
DB.close(rs, ps);
rs = null; ps = null;
}
return(result);
}