BF [ 1874419 ] JDBC Statement not close in a finally block - fixed for MLocator
This commit is contained in:
parent
e4152c7582
commit
6608962f25
|
@ -45,30 +45,23 @@ public class MLocator extends X_M_Locator
|
|||
+ "WHERE l.M_Warehouse_ID=lx.M_Warehouse_ID AND lx.M_Locator_ID=?) "
|
||||
+ "ORDER BY Created";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setInt (1, M_Locator_ID);
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
retValue = new MLocator (ctx, rs, trxName);
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
try
|
||||
finally
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
|
@ -91,6 +84,7 @@ public class MLocator extends X_M_Locator
|
|||
MLocator retValue = null;
|
||||
String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=? AND X=? AND Y=? AND Z=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
|
@ -98,26 +92,18 @@ public class MLocator extends X_M_Locator
|
|||
pstmt.setString(2, X);
|
||||
pstmt.setString(3, Y);
|
||||
pstmt.setString(4, Z);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
retValue = new MLocator (ctx, rs, null);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
s_log.log(Level.SEVERE, "get", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
catch (SQLException ex1)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
//
|
||||
if (retValue == null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue