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;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.model.*;
import org.compiere.util.*;
import org.compiere.process.*;
//import compiere.model.*;
import org.compiere.model.MProduct;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.eevolution.model.MPPProductBOMLine;
/**
* CalculateLowLevel for MRP
*
@ -50,17 +48,16 @@ public class CalculateLowLevel extends SvrProcess
ProcessInfoParameter[] para = getParameter();
} // prepare
protected String doIt() throws Exception
{
String sql = "SELECT p.M_Product_ID FROM M_Product p WHERE AD_Client_ID = " + AD_Client_ID;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery();
while (rs.next())
{
@ -70,21 +67,28 @@ public class CalculateLowLevel extends SvrProcess
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.setLowLevel(lowlevel);
product.save();
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.severe("Error: " + e.getLocalizedMessage() + sql);
return "@Error@";
}
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";
}
}