diff --git a/base/src/org/compiere/model/MAsset.java b/base/src/org/compiere/model/MAsset.java index d1b89a4f7f..5d851b4f88 100644 --- a/base/src/org/compiere/model/MAsset.java +++ b/base/src/org/compiere/model/MAsset.java @@ -43,30 +43,23 @@ public class MAsset extends X_A_Asset MAsset retValue = null; String sql = "SELECT * FROM A_Asset WHERE M_InOutLine_ID=?"; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql, trxName); pstmt.setInt (1, M_InOutLine_ID); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); if (rs.next ()) retValue = new MAsset (ctx, rs, trxName); - rs.close (); - pstmt.close (); - pstmt = null; } catch (Exception e) { s_log.log (Level.SEVERE, sql, e); } - try + finally { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; } return retValue; } // getFromShipment @@ -260,16 +253,14 @@ public class MAsset extends X_A_Asset String sql = "SELECT * FROM A_Asset_Delivery WHERE A_Asset_ID=? ORDER BY Created DESC"; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt.setInt(1, getA_Asset_ID()); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); while (rs.next()) list.add(new MAssetDelivery(getCtx(), rs, get_TrxName())); - rs.close(); - pstmt.close(); - pstmt = null; } catch (Exception e) { @@ -277,14 +268,8 @@ public class MAsset extends X_A_Asset } finally { - try - { - if (pstmt != null) - pstmt.close (); - } - catch (Exception e) - {} - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; } // MAssetDelivery[] retValue = new MAssetDelivery[list.size()];