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

organize imports
+ re-format
This commit is contained in:
tspc 2008-07-14 04:11:00 +00:00
parent b4750dad0a
commit a5a40bdb81
1 changed files with 46 additions and 42 deletions

View File

@ -16,19 +16,17 @@
package org.eevolution.process; package org.eevolution.process;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.math.*; import org.compiere.model.MProduct;
import java.sql.*; import org.compiere.process.ProcessInfoParameter;
import java.util.*; import org.compiere.process.SvrProcess;
import java.util.logging.*; import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.model.*;
import org.compiere.util.*;
import org.compiere.process.*;
//import compiere.model.*;
import org.eevolution.model.MPPProductBOMLine; import org.eevolution.model.MPPProductBOMLine;
/** /**
* CalculateLowLevel for MRP * CalculateLowLevel for MRP
* *
@ -39,7 +37,7 @@ public class CalculateLowLevel extends SvrProcess
{ {
/** */ /** */
private int AD_Client_ID = 0 ; private int AD_Client_ID = 0;
/** /**
* Prepare - e.g., get Parameters. * Prepare - e.g., get Parameters.
@ -47,44 +45,50 @@ public class CalculateLowLevel extends SvrProcess
protected void prepare() protected void prepare()
{ {
AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID")); AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
ProcessInfoParameter[] para = getParameter(); ProcessInfoParameter[] para = getParameter();
} // prepare } // prepare
protected String doIt() throws Exception
protected String doIt() throws Exception
{ {
String sql = "SELECT p.M_Product_ID FROM M_Product p WHERE AD_Client_ID = " + AD_Client_ID;
String sql = "SELECT p.M_Product_ID FROM M_Product p WHERE AD_Client_ID = " + AD_Client_ID;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql,get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int m_M_Product_ID = rs.getInt(1);
if (m_M_Product_ID != 0)
{
MProduct product = new MProduct(getCtx(), m_M_Product_ID,get_TrxName());
MPPProductBOMLine bomline = new MPPProductBOMLine(getCtx(), 0 , get_TrxName());
int lowlevel = bomline.getLowLevel(m_M_Product_ID);
product.set_CustomColumn("LowLevel", lowlevel);
product.save();
}
}
rs.close();
pstmt.close();
int m_M_Product_ID = rs.getInt(1);
if (m_M_Product_ID != 0)
{
MProduct product = new MProduct(getCtx(), m_M_Product_ID, get_TrxName());
MPPProductBOMLine bomline = new MPPProductBOMLine(getCtx(), 0, get_TrxName());
int lowlevel = bomline.getLowLevel(m_M_Product_ID);
product.setLowLevel(lowlevel);
product.save();
}
}
}
catch (SQLException e)
{
log.severe("Error: " + e.getLocalizedMessage() + sql);
return "@Error@";
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "doIt - " + sql, e); log.severe("Error: " + e.getLocalizedMessage());
return "@Error@";
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
return "ok"; return "OK";
} }
} }