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

Organize Imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 09:40:53 +00:00
parent e9675e3e9d
commit dc20d4e7b3
1 changed files with 20 additions and 28 deletions

View File

@ -16,10 +16,16 @@
*****************************************************************************/
package org.compiere.model;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.util.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Msg;
/**
@ -41,29 +47,22 @@ public class MAcctProcessor extends X_C_AcctProcessor
ArrayList<MAcctProcessor> list = new ArrayList<MAcctProcessor>();
String sql = "SELECT * FROM C_AcctProcessor WHERE IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAcctProcessor (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getActive", e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
MAcctProcessor[] retValue = new MAcctProcessor[list.size ()];
list.toArray (retValue);
@ -153,30 +152,23 @@ public class MAcctProcessor extends X_C_AcctProcessor
+ "WHERE C_AcctProcessor_ID=? "
+ "ORDER BY Created DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_AcctProcessor_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAcctProcessorLog (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
MAcctProcessorLog[] retValue = new MAcctProcessorLog[list.size ()];
list.toArray (retValue);