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

organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-19 13:33:08 +00:00
parent 9b2adb058e
commit 40c4adc801
1 changed files with 19 additions and 18 deletions

View File

@ -16,12 +16,21 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.process; package org.compiere.process;
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.MBPartner;
import java.util.logging.*; import org.compiere.model.MConversionRate;
import org.compiere.util.*; import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MProject;
import org.compiere.model.MTimeExpense;
import org.compiere.model.MTimeExpenseLine;
import org.compiere.util.DB;
import org.compiere.util.Env;
/** /**
* Create Sales Orders from Expense Reports * Create Sales Orders from Expense Reports
@ -101,6 +110,7 @@ public class ExpenseSOrder extends SvrProcess
MTimeExpense te = null; MTimeExpense te = null;
// //
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
@ -112,7 +122,7 @@ public class ExpenseSOrder extends SvrProcess
pstmt.setTimestamp(par++, p_DateFrom); pstmt.setTimestamp(par++, p_DateFrom);
if (m_DateTo != null) if (m_DateTo != null)
pstmt.setTimestamp(par++, m_DateTo); pstmt.setTimestamp(par++, m_DateTo);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) // ********* Expense Line Loop while (rs.next()) // ********* Expense Line Loop
{ {
MTimeExpenseLine tel = new MTimeExpenseLine(getCtx(), rs, get_TrxName()); MTimeExpenseLine tel = new MTimeExpenseLine(getCtx(), rs, get_TrxName());
@ -137,24 +147,15 @@ public class ExpenseSOrder extends SvrProcess
// //
processLine (te, tel, oldBPartner); processLine (te, tel, oldBPartner);
} // ********* Expense Line Loop } // ********* Expense Line Loop
rs.close(); }
pstmt.close();
pstmt = null;
}
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null; pstmt = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
} }
completeOrder (); completeOrder ();