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

organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-19 13:23:34 +00:00
parent 9cc5602fa6
commit 6272c772c0
1 changed files with 17 additions and 18 deletions

View File

@ -16,12 +16,18 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.sla; package org.compiere.sla;
import java.math.*; import java.math.BigDecimal;
import java.sql.*; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.logging.Level;
import org.compiere.model.*; import org.compiere.model.MInOut;
import java.util.logging.*; import org.compiere.model.MSLAGoal;
import org.compiere.util.*; import org.compiere.model.MSLAMeasure;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* SLA Delivery Accuracy. * SLA Delivery Accuracy.
@ -68,12 +74,13 @@ public class DeliveryAccuracy extends SLACriteria
+ " AND m.Record_ID=io.M_InOut_ID)"; + " AND m.Record_ID=io.M_InOut_ID)";
int counter = 0; int counter = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, goal.getC_BPartner_ID()); pstmt.setInt (1, goal.getC_BPartner_ID());
pstmt.setInt (2, goal.getPA_SLA_Goal_ID()); pstmt.setInt (2, goal.getPA_SLA_Goal_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
int M_InOut_ID = rs.getInt(1); int M_InOut_ID = rs.getInt(1);
@ -89,23 +96,15 @@ public class DeliveryAccuracy extends SLACriteria
counter++; counter++;
} }
} }
rs.close (); }
pstmt.close ();
pstmt = null;
}
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "createMeasures", e); log.log(Level.SEVERE, "createMeasures", e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
return counter; return counter;
} // createMeasures } // createMeasures