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

Organize Imports
Parameterize ArrayList<String>
This commit is contained in:
Redhuan D. Oon 2008-02-08 09:36:22 +00:00
parent 434a2b8a7b
commit e9675e3e9d
1 changed files with 37 additions and 22 deletions

View File

@ -16,15 +16,37 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.awt.*; import java.awt.Dimension;
import java.io.*; import java.awt.Image;
import java.sql.*; import java.io.Serializable;
import java.util.*; import java.sql.PreparedStatement;
import java.util.logging.*; import java.sql.ResultSet;
import javax.swing.*; import java.sql.Timestamp;
import org.apache.ecs.xhtml.*; import java.util.ArrayList;
import org.compiere.plaf.*; import java.util.HashSet;
import org.compiere.util.*; import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.Icon;
import org.apache.ecs.xhtml.a;
import org.apache.ecs.xhtml.h2;
import org.apache.ecs.xhtml.h3;
import org.apache.ecs.xhtml.h4;
import org.apache.ecs.xhtml.i;
import org.apache.ecs.xhtml.p;
import org.apache.ecs.xhtml.strong;
import org.apache.ecs.xhtml.table;
import org.apache.ecs.xhtml.td;
import org.apache.ecs.xhtml.th;
import org.apache.ecs.xhtml.tr;
import org.compiere.plaf.CompiereColor;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.WebDoc;
/** /**
* Window Model * Window Model
@ -147,7 +169,7 @@ public class GridWindow implements Serializable
// Set Link Column // Set Link Column
if (mTab.getLinkColumnName().length() == 0) if (mTab.getLinkColumnName().length() == 0)
{ {
ArrayList parents = mTab.getParentColumnNames(); ArrayList<String> parents = mTab.getParentColumnNames();
// No Parent - no link // No Parent - no link
if (parents.size() == 0) if (parents.size() == 0)
; ;
@ -520,11 +542,12 @@ public class GridWindow implements Serializable
+ " INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) " + " INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) "
+ "WHERE w.AD_Window_ID=?"; + "WHERE w.AD_Window_ID=?";
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_Window_ID()); pstmt.setInt (1, getAD_Window_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
{ {
m_modelUpdated = rs.getTimestamp(1); // Window m_modelUpdated = rs.getTimestamp(1); // Window
@ -541,23 +564,15 @@ public class GridWindow implements Serializable
if (ts.after(m_modelUpdated)) if (ts.after(m_modelUpdated))
m_modelUpdated = ts; m_modelUpdated = ts;
} }
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;
} }
} }
return m_modelUpdated; return m_modelUpdated;