From 30c8cf617afb7aa97e7ff95d9937f9b326218827 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Fri, 20 Jun 2008 12:04:58 +0000 Subject: [PATCH] org.compiere.acct.ProductInfo: db connection fix --- base/src/org/compiere/acct/ProductInfo.java | 36 ++++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/base/src/org/compiere/acct/ProductInfo.java b/base/src/org/compiere/acct/ProductInfo.java index fd744a3644..ce7be27db2 100644 --- a/base/src/org/compiere/acct/ProductInfo.java +++ b/base/src/org/compiere/acct/ProductInfo.java @@ -82,11 +82,13 @@ public class ProductInfo + "FROM M_Product_Category pc" + " INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) " + "WHERE p.M_Product_ID=?"; // #1 + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_M_Product_ID); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { m_productType = rs.getString(1); @@ -100,13 +102,15 @@ public class ProductInfo m_isBOM = "Y".equals(rs.getString(7)); m_isStocked = "Y".equals(rs.getString(8)); } - rs.close(); - pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } + finally { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } } // init /** @@ -301,11 +305,13 @@ public class ProductInfo BigDecimal PriceList = null; BigDecimal PriceStd = null; BigDecimal PriceLimit = null; + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); + pstmt = DB.prepareStatement(sql.toString(), null); pstmt.setInt(1, m_M_Product_ID); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { C_Currency_ID = rs.getInt(1); @@ -313,13 +319,15 @@ public class ProductInfo PriceStd = rs.getBigDecimal(3); PriceLimit = rs.getBigDecimal(4); } - rs.close(); - pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql.toString(), e); } + finally { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } // nothing found if (C_Currency_ID == 0) return null; @@ -352,11 +360,13 @@ public class ProductInfo BigDecimal PriceList = null; BigDecimal PricePO = null; BigDecimal PriceLastPO = null; + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, m_M_Product_ID); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { C_Currency_ID = rs.getInt(1); @@ -364,13 +374,15 @@ public class ProductInfo PricePO = rs.getBigDecimal(3); PriceLastPO = rs.getBigDecimal(4); } - rs.close(); - pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); } + finally { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } // nothing found if (C_Currency_ID == 0) return null;