*BF [ 1874419 ] JDBC Statement not close in a finally block
Organize Imports
This commit is contained in:
parent
c9678e1527
commit
7e51491b76
|
@ -16,13 +16,19 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.process;
|
package org.compiere.process;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.sql.PreparedStatement;
|
||||||
import java.util.logging.*;
|
import java.sql.ResultSet;
|
||||||
import java.math.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.model.MLocator;
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.MMovement;
|
||||||
|
import org.compiere.model.MMovementLine;
|
||||||
|
import org.compiere.model.MRefList;
|
||||||
|
import org.compiere.model.MStorage;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StorageCleanup
|
* StorageCleanup
|
||||||
|
@ -90,33 +96,26 @@ public class StorageCleanup extends SvrProcess
|
||||||
+ " AND s.M_Locator_ID=sl.M_Locator_ID"
|
+ " AND s.M_Locator_ID=sl.M_Locator_ID"
|
||||||
+ " AND sl.M_Warehouse_ID=swl.M_Warehouse_ID)";
|
+ " AND sl.M_Warehouse_ID=swl.M_Warehouse_ID)";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||||
pstmt.setInt(1, Env.getAD_Client_ID(getCtx()));
|
pstmt.setInt(1, Env.getAD_Client_ID(getCtx()));
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
{
|
{
|
||||||
lines += move (new MStorage(getCtx(), rs, get_TrxName()));
|
lines += move (new MStorage(getCtx(), rs, get_TrxName()));
|
||||||
}
|
}
|
||||||
rs.close ();
|
}
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "#" + lines;
|
return "#" + lines;
|
||||||
|
@ -260,35 +259,27 @@ public class StorageCleanup extends SvrProcess
|
||||||
+ " AND sl.M_Warehouse_ID=x.M_Warehouse_ID) "
|
+ " AND sl.M_Warehouse_ID=x.M_Warehouse_ID) "
|
||||||
+ "ORDER BY M_AttributeSetInstance_ID";
|
+ "ORDER BY M_AttributeSetInstance_ID";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||||
pstmt.setInt (1, M_Product_ID);
|
pstmt.setInt (1, M_Product_ID);
|
||||||
pstmt.setInt (2, M_Locator_ID);
|
pstmt.setInt (2, M_Locator_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
{
|
{
|
||||||
list.add (new MStorage (getCtx(), rs, get_TrxName()));
|
list.add (new MStorage (getCtx(), rs, get_TrxName()));
|
||||||
}
|
}
|
||||||
rs.close ();
|
}
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
MStorage[] retValue = new MStorage[list.size()];
|
MStorage[] retValue = new MStorage[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
Loading…
Reference in New Issue