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

organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-19 10:52:49 +00:00
parent 5e752fa1fb
commit 1d2ac06ad9
1 changed files with 22 additions and 19 deletions

View File

@ -16,12 +16,22 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.*; import java.sql.PreparedStatement;
import java.text.*; import java.sql.ResultSet;
import java.util.*; import java.sql.SQLException;
import java.util.logging.*; import java.text.DateFormat;
import org.compiere.*; import java.text.SimpleDateFormat;
import org.compiere.util.*; import java.util.ArrayList;
import java.util.Locale;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.Adempiere;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.compiere.util.Msg;
/** /**
* Language Model * Language Model
@ -131,32 +141,25 @@ public class MLanguage extends X_AD_Language
String sql = "SELECT * FROM AD_Language " String sql = "SELECT * FROM AD_Language "
+ "WHERE IsSystemLanguage='Y' AND IsBaseLanguage='N' AND IsActive='Y'"; + "WHERE IsSystemLanguage='Y' AND IsBaseLanguage='N' AND IsActive='Y'";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MLanguage language = new MLanguage (ctx, rs, null); MLanguage language = new MLanguage (ctx, rs, null);
language.maintain(true); language.maintain(true);
} }
rs.close (); }
pstmt.close ();
pstmt = null;
}
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_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;
} }
} // maintain } // maintain