* ensure statement is close after use.

This commit is contained in:
Heng Sin Low 2007-11-27 23:09:42 +00:00
parent a08bcda86e
commit 072a31b274
1 changed files with 24 additions and 21 deletions

View File

@ -342,12 +342,15 @@ public final class InfoProduct extends Info implements ActionListener
if(rs.getString("DocumentNote") != null) if(rs.getString("DocumentNote") != null)
fieldDescription.setText(rs.getString("DocumentNote")); fieldDescription.setText(rs.getString("DocumentNote"));
rs.close(); rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.WARNING, sql, e);
}
finally
{
if (pstmt != null) DB.close(pstmt);
pstmt = null;
} }
try { try {
@ -358,7 +361,12 @@ public final class InfoProduct extends Info implements ActionListener
if(rs.next()) if(rs.next())
M_Product_ID = rs.getInt(1); M_Product_ID = rs.getInt(1);
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception log.log(Level.WARNING, sql, e);
}
finally
{
if (pstmt != null) DB.close(pstmt);
pstmt = null;
} }
sql = m_sqlSubstitute; sql = m_sqlSubstitute;
@ -370,10 +378,13 @@ public final class InfoProduct extends Info implements ActionListener
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
substituteTbl.loadTable(rs); substituteTbl.loadTable(rs);
rs.close(); rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception log.log(Level.WARNING, sql, e);
}
finally
{
if (pstmt != null) DB.close(pstmt);
pstmt = null;
} }
sql = m_sqlRelated; sql = m_sqlRelated;
@ -385,20 +396,12 @@ public final class InfoProduct extends Info implements ActionListener
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
relatedTbl.loadTable(rs); relatedTbl.loadTable(rs);
rs.close(); rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception log.log(Level.WARNING, sql, e);
} }
finally
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
if (pstmt != null) DB.close(pstmt);
pstmt = null; pstmt = null;
} }
} // refresh } // refresh