BF1874419 JDBC Statement not close in a finally block

+ Fix indentation and format
This commit is contained in:
tspc 2008-08-06 00:46:10 +00:00
parent d6dbceefbe
commit 70d98a06ef
1 changed files with 192 additions and 209 deletions

View File

@ -16,15 +16,16 @@
package org.eevolution.process; package org.eevolution.process;
import java.util.Properties; import java.math.BigDecimal;
import java.util.logging.*; import java.sql.PreparedStatement;
import java.math.*; import java.sql.ResultSet;
import java.sql.*; import java.util.logging.Level;
import org.compiere.model.MWarehouse;
import org.compiere.model.*; import org.compiere.process.ProcessInfoParameter;
import org.compiere.util.*; import org.compiere.process.SvrProcess;
import org.compiere.process.*; import org.compiere.util.DB;
import org.compiere.util.Env;
import org.eevolution.model.MPPProductPlanning; import org.eevolution.model.MPPProductPlanning;
/** /**
@ -59,51 +60,38 @@ public class CreateProductPlanning extends SvrProcess
private int m_AD_Org_ID = 0; private int m_AD_Org_ID = 0;
private int m_AD_Client_ID = 0; private int m_AD_Client_ID = 0;
/** /**
* Prepare - e.g., get Parameters. * Prepare - e.g., get Parameters.
*/ */
protected void prepare() protected void prepare()
{ {
m_AD_Client_ID = Env.getAD_Client_ID(getCtx()); m_AD_Client_ID = Env.getAD_Client_ID(getCtx());
ProcessInfoParameter[] para = getParameter(); ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++) for (int i = 0; i < para.length; i++)
{ {
String name = para[i].getParameterName(); String name = para[i].getParameterName();
if (para[i].getParameter() == null) if (para[i].getParameter() == null)
; ;
else if (name.equals("M_Product_Category_ID")) else if (name.equals("M_Product_Category_ID"))
{ {
p_M_Product_Category_ID = ((BigDecimal)para[i].getParameter()).intValue(); p_M_Product_Category_ID = ((BigDecimal)para[i].getParameter()).intValue();
} }
else if (name.equals("M_Warehouse_ID")) else if (name.equals("M_Warehouse_ID"))
{ {
p_M_Warehouse_ID = ((BigDecimal)para[i].getParameter()).intValue(); p_M_Warehouse_ID = ((BigDecimal)para[i].getParameter()).intValue();
} }
else if (name.equals("S_Resource_ID")) else if (name.equals("S_Resource_ID"))
{ {
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue(); p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
} }
else if (name.equals("IsCreatePlan")) else if (name.equals("IsCreatePlan"))
{ {
p_CreatePlan = "Y".equals((String)para[i].getParameter()); p_CreatePlan = "Y".equals((String)para[i].getParameter());
} }
else if (name.equals("IsMPS")) else if (name.equals("IsMPS"))
{ {
p_MPS = "Y".equals((String)para[i].getParameter()); p_MPS = "Y".equals((String)para[i].getParameter());
} }
else if (name.equals("DD_NetworkDistribution_ID")) else if (name.equals("DD_NetworkDistribution_ID"))
{ {
@ -112,13 +100,11 @@ public class CreateProductPlanning extends SvrProcess
else if (name.equals("AD_Workflow_ID")) else if (name.equals("AD_Workflow_ID"))
{ {
p_AD_Workflow_ID = ((BigDecimal)para[i].getParameter()).intValue(); p_AD_Workflow_ID = ((BigDecimal)para[i].getParameter()).intValue();
} }
else if (name.equals("TimeFence")) else if (name.equals("TimeFence"))
{ {
p_TimeFence = ((BigDecimal)para[i].getParameter()); p_TimeFence = ((BigDecimal)para[i].getParameter());
} }
else if (name.equals("TransfertTime")) else if (name.equals("TransfertTime"))
{ {
p_TransferTime = ((BigDecimal)para[i].getParameter()); p_TransferTime = ((BigDecimal)para[i].getParameter());
@ -171,23 +157,22 @@ public class CreateProductPlanning extends SvrProcess
else else
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name); log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
} }
if(p_M_Warehouse_ID > 0 ) if(p_M_Warehouse_ID > 0 )
{ {
MWarehouse w = MWarehouse.get(getCtx(), p_M_Warehouse_ID); MWarehouse w = MWarehouse.get(getCtx(), p_M_Warehouse_ID);
m_AD_Org_ID = w.getAD_Org_ID(); m_AD_Org_ID = w.getAD_Org_ID();
} }
} // prepare } // prepare
/********************** /***************************************************************************
* Create Data Planning record * Create Data Planning record
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
String sql = null; String sql = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
if (p_M_Product_Category_ID > 0 ) if (p_M_Product_Category_ID > 0 )
sql = "SELECT p.M_Product_ID FROM M_Product p WHERE p.AD_Client_ID= ? AND p.M_Product_Category_ID = ? "; sql = "SELECT p.M_Product_ID FROM M_Product p WHERE p.AD_Client_ID= ? AND p.M_Product_Category_ID = ? ";
@ -201,13 +186,10 @@ public class CreateProductPlanning extends SvrProcess
pstmt.setInt(1, m_AD_Client_ID); pstmt.setInt(1, m_AD_Client_ID);
pstmt.setInt(2, p_M_Product_Category_ID); pstmt.setInt(2, p_M_Product_Category_ID);
} }
else else pstmt.setInt(1, m_AD_Client_ID);
pstmt.setInt(1, m_AD_Client_ID); rs = pstmt.executeQuery ();
ResultSet rs = pstmt.executeQuery ();
while (rs.next()) while (rs.next())
{ {
int M_Product_ID = rs.getInt(1); int M_Product_ID = rs.getInt(1);
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(),m_AD_Client_ID , m_AD_Org_ID , p_M_Warehouse_ID, p_S_Resource_ID,M_Product_ID, get_TrxName()); MPPProductPlanning pp = MPPProductPlanning.get(getCtx(),m_AD_Client_ID , m_AD_Org_ID , p_M_Warehouse_ID, p_S_Resource_ID,M_Product_ID, get_TrxName());
// Create Product Data Planning // Create Product Data Planning
@ -264,16 +246,17 @@ public class CreateProductPlanning extends SvrProcess
pp.save(); pp.save();
} }
} }
DB.close(rs);
DB.close(pstmt);
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE,"doIt - " + sql, e); log.log(Level.SEVERE,"doIt - " + sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "ok"; return "ok";
} }
} }