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

*Organize imports

*Parameterized entry
This commit is contained in:
Redhuan D. Oon 2008-02-08 08:51:29 +00:00
parent 37bfc101b5
commit 75a342b900
1 changed files with 35 additions and 31 deletions

View File

@ -16,11 +16,31 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.util; package org.compiere.util;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.util.ArrayList;
import org.compiere.model.*; import java.util.Properties;
import org.compiere.wf.*; import java.util.logging.Level;
import org.compiere.model.MAdvertisement;
import org.compiere.model.MAsset;
import org.compiere.model.MBPartner;
import org.compiere.model.MCommissionRun;
import org.compiere.model.MDocType;
import org.compiere.model.MInOut;
import org.compiere.model.MInterestArea;
import org.compiere.model.MInvoice;
import org.compiere.model.MNote;
import org.compiere.model.MOrder;
import org.compiere.model.MPayment;
import org.compiere.model.MRegistration;
import org.compiere.model.MRequest;
import org.compiere.model.MRequestType;
import org.compiere.model.MRfQ;
import org.compiere.model.MRfQResponse;
import org.compiere.model.MTimeExpense;
import org.compiere.model.X_AD_UserBPAccess;
import org.compiere.wf.MWFActivity;
/** /**
@ -220,16 +240,14 @@ public class WebInfo
+ " AND DocStatus NOT IN ('DR','IN') " + " AND DocStatus NOT IN ('DR','IN') "
+ "ORDER BY DocumentNo DESC"; + "ORDER BY DocumentNo DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getC_BPartner_ID()); pstmt.setInt(1, getC_BPartner_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MOrder (m_ctx, rs, null)); list.add(new MOrder (m_ctx, rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -237,14 +255,8 @@ public class WebInfo
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null; pstmt = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
} }
log.fine("#" + list.size()); log.fine("#" + list.size());
return list; return list;
@ -354,7 +366,7 @@ public class WebInfo
* Get Own Requests * Get Own Requests
* @return Array of Own Requests * @return Array of Own Requests
*/ */
public ArrayList getRequestsOwn () public ArrayList<MRequest> getRequestsOwn ()
{ {
return getRequests(true); return getRequests(true);
} // getRequestsOwn } // getRequestsOwn
@ -363,7 +375,7 @@ public class WebInfo
* Get Own Requests * Get Own Requests
* @return Array of Assigned Requests * @return Array of Assigned Requests
*/ */
public ArrayList getRequestsAssigned () public ArrayList<MRequest> getRequestsAssigned ()
{ {
return getRequests(false); return getRequests(false);
} // getRequestsAssigned } // getRequestsAssigned
@ -1164,16 +1176,14 @@ public class WebInfo
+ "WHERE C_BPartner_ID=? " + "WHERE C_BPartner_ID=? "
+ "ORDER BY Created DESC"; + "ORDER BY Created DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getC_BPartner_ID()); pstmt.setInt(1, getC_BPartner_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MTimeExpense (m_ctx, rs, null)); list.add(new MTimeExpense (m_ctx, rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -1181,14 +1191,8 @@ public class WebInfo
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null; pstmt = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
} }
log.fine("#" + list.size()); log.fine("#" + list.size());
return list; return list;