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

*Organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 19:13:13 +00:00
parent 0eb0840aaa
commit b46a2dd4ed
1 changed files with 14 additions and 17 deletions

View File

@ -16,10 +16,13 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.util.ArrayList;
import org.compiere.util.*; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
/** /**
* Alert Model * Alert Model
@ -80,31 +83,25 @@ public class MAlert extends X_AD_Alert
+ "WHERE AD_Alert_ID=?"; + "WHERE AD_Alert_ID=?";
ArrayList<MAlertRule> list = new ArrayList<MAlertRule>(); ArrayList<MAlertRule> list = new ArrayList<MAlertRule>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_Alert_ID()); pstmt.setInt (1, getAD_Alert_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new MAlertRule (getCtx(), rs, null)); list.add (new MAlertRule (getCtx(), rs, null));
rs.close (); }
pstmt.close ();
pstmt = null;
}
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
// //
m_rules = new MAlertRule[list.size ()]; m_rules = new MAlertRule[list.size ()];
list.toArray (m_rules); list.toArray (m_rules);