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

Organize Imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 10:04:43 +00:00
parent 6400fd0d45
commit 6039fa88f2
1 changed files with 14 additions and 17 deletions

View File

@ -16,12 +16,16 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.awt.*; import java.awt.Dimension;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.*; import org.compiere.util.CLogger;
import org.compiere.util.DB;
/** /**
* Window Model * Window Model
@ -92,30 +96,23 @@ public class MWindow extends X_AD_Window
String sql = "SELECT * FROM AD_Tab WHERE AD_Window_ID=? ORDER BY SeqNo"; String sql = "SELECT * FROM AD_Tab WHERE AD_Window_ID=? ORDER BY SeqNo";
ArrayList<MTab> list = new ArrayList<MTab>(); ArrayList<MTab> list = new ArrayList<MTab>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, getAD_Window_ID()); pstmt.setInt (1, getAD_Window_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new MTab (getCtx(), rs, trxName)); list.add (new MTab (getCtx(), rs, trxName));
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_tabs = new MTab[list.size ()]; m_tabs = new MTab[list.size ()];