MCash:
* BF [ 1874419 ] JDBC Statement not close in a finally block * organized imports
This commit is contained in:
parent
34f30961d5
commit
8219afb5ca
|
|
@ -16,13 +16,23 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
import java.math.*;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.PreparedStatement;
|
||||||
import java.util.*;
|
import java.sql.ResultSet;
|
||||||
import java.util.logging.*;
|
import java.sql.Timestamp;
|
||||||
import org.compiere.process.*;
|
import java.util.ArrayList;
|
||||||
import org.compiere.util.*;
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.DocumentEngine;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.TimeUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cash Journal Model
|
* Cash Journal Model
|
||||||
|
|
@ -59,32 +69,25 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
+ " AND cb.C_Currency_ID=?)"; // #3
|
+ " AND cb.C_Currency_ID=?)"; // #3
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, trxName);
|
pstmt = DB.prepareStatement (sql, trxName);
|
||||||
pstmt.setInt (1, AD_Org_ID);
|
pstmt.setInt (1, AD_Org_ID);
|
||||||
pstmt.setTimestamp (2, TimeUtil.getDay(dateAcct));
|
pstmt.setTimestamp (2, TimeUtil.getDay(dateAcct));
|
||||||
pstmt.setInt (3, C_Currency_ID);
|
pstmt.setInt (3, C_Currency_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
retValue = new MCash (ctx, rs, trxName);
|
retValue = new MCash (ctx, rs, trxName);
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_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;
|
|
||||||
}
|
}
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
@ -121,31 +124,24 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
+ " AND TRUNC(c.StatementDate)=?" // #2
|
+ " AND TRUNC(c.StatementDate)=?" // #2
|
||||||
+ " AND c.Processed='N'";
|
+ " AND c.Processed='N'";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, trxName);
|
pstmt = DB.prepareStatement (sql, trxName);
|
||||||
pstmt.setInt (1, C_CashBook_ID);
|
pstmt.setInt (1, C_CashBook_ID);
|
||||||
pstmt.setTimestamp (2, TimeUtil.getDay(dateAcct));
|
pstmt.setTimestamp (2, TimeUtil.getDay(dateAcct));
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
retValue = new MCash (ctx, rs, trxName);
|
retValue = new MCash (ctx, rs, trxName);
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
s_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;
|
|
||||||
}
|
}
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
@ -249,30 +245,23 @@ public class MCash extends X_C_Cash implements DocAction
|
||||||
ArrayList<MCashLine> list = new ArrayList<MCashLine>();
|
ArrayList<MCashLine> list = new ArrayList<MCashLine>();
|
||||||
String sql = "SELECT * FROM C_CashLine WHERE C_Cash_ID=? ORDER BY Line";
|
String sql = "SELECT * FROM C_CashLine WHERE C_Cash_ID=? ORDER BY Line";
|
||||||
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, getC_Cash_ID());
|
pstmt.setInt (1, getC_Cash_ID());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
list.add (new MCashLine (getCtx(), rs, get_TrxName()));
|
list.add (new MCashLine (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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lines = new MCashLine[list.size ()];
|
m_lines = new MCashLine[list.size ()];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue