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

organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-19 10:34:53 +00:00
parent 67b98722a5
commit 24c5b135f4
1 changed files with 26 additions and 18 deletions

View File

@ -16,12 +16,26 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.wf; package org.compiere.wf;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.sql.SQLException;
import org.compiere.model.*; import java.util.ArrayList;
import org.compiere.process.*; import java.util.Calendar;
import org.compiere.util.*; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.MMenu;
import org.compiere.model.MWindow;
import org.compiere.model.X_AD_WF_Node;
import org.compiere.model.X_AD_Workflow;
import org.compiere.process.ProcessInfo;
import org.compiere.process.StateEngine;
import org.compiere.util.CCache;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
/** /**
* WorkFlow Model * WorkFlow Model
@ -72,10 +86,11 @@ public class MWorkflow extends X_AD_Workflow
String oldKey = ""; String oldKey = "";
String newKey = null; String newKey = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); //Bug 1568766 pstmt = DB.prepareStatement (sql, trxName); //Bug 1568766
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MWorkflow wf = new MWorkflow (ctx, rs, null); MWorkflow wf = new MWorkflow (ctx, rs, null);
@ -90,24 +105,17 @@ public class MWorkflow extends X_AD_Workflow
oldKey = newKey; oldKey = newKey;
list.add(wf); list.add(wf);
} }
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;
} }
// Last one // Last one
if (list.size() > 0) if (list.size() > 0)
{ {