BF [ 1874419 ] JDBC Statement not close in a finally block

This commit is contained in:
teo_sarca 2008-01-26 10:05:42 +00:00
parent bcb3ff779a
commit 609f2e8f0e
1 changed files with 10 additions and 26 deletions

View File

@ -184,12 +184,13 @@ public class PAttributeInstance extends CDialog
+ " ON (bp.C_BPartner_ID=bpp.C_BPartner_ID AND bpp.M_Product_ID=?) "
+ "WHERE bp.C_BPartner_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
ShelfLifeMinPct = rs.getInt(1); // BP
@ -198,23 +199,14 @@ public class PAttributeInstance extends CDialog
ShelfLifeMinDays = pct;
ShelfLifeMinDays = rs.getInt(3);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
if (ShelfLifeMinPct > 0)
{
@ -258,31 +250,23 @@ public class PAttributeInstance extends CDialog
//
log.finest(sql);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
m_table.loadTable(rs);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
enableButtons();
} // refresh