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

Organize Imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 09:57:28 +00:00
parent f73b7e164b
commit c9678e1527
1 changed files with 15 additions and 17 deletions

View File

@ -16,10 +16,15 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.logging.*; import java.sql.ResultSet;
import org.compiere.model.*; import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.model.MColumn;
import org.compiere.model.MField;
import org.compiere.model.MTab;
import org.compiere.util.AdempiereSystemError;
import org.compiere.util.DB;
/** /**
@ -65,13 +70,14 @@ public class TabCreateFields extends SvrProcess
+ " AND IsActive='Y' " + " AND IsActive='Y' "
+ "ORDER BY Name"; + "ORDER BY Name";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, tab.getAD_Table_ID()); pstmt.setInt (1, tab.getAD_Table_ID());
pstmt.setInt (2, tab.getAD_Tab_ID()); pstmt.setInt (2, tab.getAD_Tab_ID());
pstmt.setInt (3, tab.getAD_Table_ID()); pstmt.setInt (3, tab.getAD_Table_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MColumn column = new MColumn (getCtx(), rs, get_TrxName()); MColumn column = new MColumn (getCtx(), rs, get_TrxName());
@ -86,23 +92,15 @@ public class TabCreateFields extends SvrProcess
count++; count++;
} }
} }
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 "@Created@ #" + count; return "@Created@ #" + count;
} // doIt } // doIt