org.compiere.acct.ProductInfo: db connection fix

This commit is contained in:
teo_sarca 2008-06-20 12:04:58 +00:00
parent ff35be4493
commit 30c8cf617a
1 changed files with 24 additions and 12 deletions

View File

@ -82,11 +82,13 @@ public class ProductInfo
+ "FROM M_Product_Category pc" + "FROM M_Product_Category pc"
+ " INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) " + " INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) "
+ "WHERE p.M_Product_ID=?"; // #1 + "WHERE p.M_Product_ID=?"; // #1
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
m_productType = rs.getString(1); m_productType = rs.getString(1);
@ -100,13 +102,15 @@ public class ProductInfo
m_isBOM = "Y".equals(rs.getString(7)); m_isBOM = "Y".equals(rs.getString(7));
m_isStocked = "Y".equals(rs.getString(8)); m_isStocked = "Y".equals(rs.getString(8));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // init } // init
/** /**
@ -301,11 +305,13 @@ public class ProductInfo
BigDecimal PriceList = null; BigDecimal PriceList = null;
BigDecimal PriceStd = null; BigDecimal PriceStd = null;
BigDecimal PriceLimit = null; BigDecimal PriceLimit = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
C_Currency_ID = rs.getInt(1); C_Currency_ID = rs.getInt(1);
@ -313,13 +319,15 @@ public class ProductInfo
PriceStd = rs.getBigDecimal(3); PriceStd = rs.getBigDecimal(3);
PriceLimit = rs.getBigDecimal(4); PriceLimit = rs.getBigDecimal(4);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// nothing found // nothing found
if (C_Currency_ID == 0) if (C_Currency_ID == 0)
return null; return null;
@ -352,11 +360,13 @@ public class ProductInfo
BigDecimal PriceList = null; BigDecimal PriceList = null;
BigDecimal PricePO = null; BigDecimal PricePO = null;
BigDecimal PriceLastPO = null; BigDecimal PriceLastPO = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
C_Currency_ID = rs.getInt(1); C_Currency_ID = rs.getInt(1);
@ -364,13 +374,15 @@ public class ProductInfo
PricePO = rs.getBigDecimal(3); PricePO = rs.getBigDecimal(3);
PriceLastPO = rs.getBigDecimal(4); PriceLastPO = rs.getBigDecimal(4);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// nothing found // nothing found
if (C_Currency_ID == 0) if (C_Currency_ID == 0)
return null; return null;