diff --git a/base/src/org/compiere/model/MAccount.java b/base/src/org/compiere/model/MAccount.java index c2b5532dd0..a31299767c 100644 --- a/base/src/org/compiere/model/MAccount.java +++ b/base/src/org/compiere/model/MAccount.java @@ -16,10 +16,15 @@ *****************************************************************************/ package org.compiere.model; -import java.sql.*; -import java.util.*; -import java.util.logging.*; -import org.compiere.util.*; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; +import java.util.logging.Level; + +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; /** * Account Object Entity to maintain all segment values. @@ -230,31 +235,24 @@ public class MAccount extends X_C_ValidCombination MAccount retValue = null; String sql = "SELECT * FROM C_ValidCombination WHERE C_AcctSchema_ID=? AND Alias=?"; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql, null); pstmt.setInt(1, C_AcctSchema_ID); pstmt.setString (2, alias); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); if (rs.next ()) retValue = new MAccount (ctx, rs, null); - 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; } // get @@ -377,10 +375,11 @@ public class MAccount extends X_C_ValidCombination int count = 0; int errors = 0; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql, trxName); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); while (rs.next ()) { MAccount account = new MAccount (ctx, rs, trxName); @@ -390,23 +389,15 @@ public class MAccount extends X_C_ValidCombination else errors++; } - 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; } s_log.info(where + " #" + count + ", Errors=" + errors); } // updateValueDescription