IDEMPIERE-568 Review proper closing of JDBC statements and resultsets

This commit is contained in:
Richard Morales 2013-02-19 16:08:13 -05:00
parent 434559b08a
commit 9b0c13b9f5
101 changed files with 927 additions and 1347 deletions

View File

@ -118,23 +118,29 @@ public final class ImpFormat
String sql = "SELECT t.TableName,c.ColumnName "
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsKey='Y') "
+ "WHERE t.AD_Table_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_tableName = rs.getString(1);
m_tablePK = rs.getString(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "ImpFormat.setTable", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (m_tableName == null || m_tablePK == null)
log.log(Level.SEVERE, "Data not found for AD_Table_ID=" + AD_Table_ID);
@ -269,11 +275,13 @@ public final class ImpFormat
ImpFormat retValue = null;
String sql = "SELECT * FROM AD_ImpFormat WHERE Name=?";
int ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString (1, name);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
retValue = new ImpFormat (name, rs.getInt("AD_Table_ID"), rs.getString("FormatType"));
@ -282,14 +290,18 @@ public final class ImpFormat
retValue.setSeparatorChar(rs.getString(I_AD_ImpFormat.COLUMNNAME_SeparatorChar));
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
loadRows (retValue, ID);
return retValue;
} // getFormat
@ -306,11 +318,13 @@ public final class ImpFormat
+ "FROM AD_ImpFormat_Row f,AD_Column c "
+ "WHERE f.AD_ImpFormat_ID=? AND f.AD_Column_ID=c.AD_Column_ID AND f.IsActive='Y'"
+ "ORDER BY f.SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
ImpFormatRow row = new ImpFormatRow (rs.getInt(1),
@ -322,13 +336,17 @@ public final class ImpFormat
//
format.addRow (row);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadLines
/*************************************************************************
@ -560,28 +578,33 @@ public final class ImpFormat
sql.append(find).append(")");
int count = 0;
int ID = 0;
try
if (find.length() > 0)
{
if (find.length() > 0)
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), trxName);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), trxName);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt(1);
if (count == 1)
ID = rs.getInt(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
return false;
}
// Insert Basic Record -----------------------------------------------
if (ID == 0)

View File

@ -73,29 +73,23 @@ public class MImpFormat extends X_AD_ImpFormat
+ "WHERE AD_ImpFormat_ID=? "
+ "ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getAD_ImpFormat_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MImpFormatRow (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getRows", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MImpFormatRow[] retValue = new MImpFormatRow[list.size ()];

View File

@ -581,21 +581,27 @@ public class GridField
}
else
{
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
PreparedStatement stmt = DB.prepareStatement(sql, null);
ResultSet rs = stmt.executeQuery();
stmt = DB.prepareStatement(sql, null);
rs = stmt.executeQuery();
if (rs.next())
defStr = rs.getString(1);
else
log.log(Level.WARNING, "(" + m_vo.ColumnName + ") - no Result: " + sql);
rs.close();
stmt.close();
}
catch (SQLException e)
{
log.log(Level.WARNING, "(" + m_vo.ColumnName + ") " + sql, e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
}
if (defStr != null && defStr.length() > 0)
{
@ -1721,33 +1727,27 @@ public class GridField
String sql = GridFieldVO.getSQL(ctx);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Tab_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
GridFieldVO vo = GridFieldVO.create(ctx, WindowNo, TabNo,
AD_Window_ID, AD_Tab_ID, readOnly, rs);
listVO.add(vo);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -794,21 +794,27 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
+ " INNER JOIN AD_Column cc ON (r.AD_Key=cc.AD_Column_ID) "
+ "WHERE c.AD_Reference_ID IN (18,30)" // Table/Search
+ " AND c.ColumnName=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, colName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
refColName = rs.getString(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "(ref) - Column=" + colName, e);
return query.getWhereClause();
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Reference Column found
if (refColName != null)
{
@ -834,21 +840,24 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
+ " WHERE cc.AD_Table_ID=t.AD_Table_ID AND cc.ColumnName=?)"; // #2 Tab Key Column
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, colName);
pstmt.setString(2, tabKeyColumn);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
tableName = rs.getString(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "Column=" + colName + ", Key=" + tabKeyColumn, e);
return null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Special Reference Handling
if (tabKeyColumn.equals("AD_Reference_ID"))
{
@ -1290,20 +1299,26 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
else
{
String SQL = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_vo.AD_Column_ID); // Parent Link Column
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
m_linkColumnName = rs.getString(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("AD_Column_ID=" + m_vo.AD_Column_ID + " - " + m_linkColumnName);
}
}
@ -1759,11 +1774,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
+ "FROM C_InvoiceBatchLine "
+ "WHERE C_InvoiceBatch_ID=? AND IsActive='Y'";
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Record_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
// {0} - Number of lines
@ -1777,13 +1794,17 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
arguments[2] = total;
filled = true;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, m_vo.TableName + "\nSQL=" + sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (filled)
return mf.format (arguments);
return " ";
@ -2095,28 +2116,34 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
+ "FROM AD_Private_Access "
+ "WHERE AD_User_ID=? AND AD_Table_ID=? AND IsActive='Y' "
+ "ORDER BY Record_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
if (m_Lock == null)
m_Lock = new ArrayList<Integer>();
else
m_Lock.clear();
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, m_vo.AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Integer key = new Integer(rs.getInt(1));
m_Lock.add(key);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("#" + m_Lock.size());
} // loadLooks

View File

@ -285,11 +285,13 @@ public class GridTabVO implements Evaluatee, Serializable
mTabVO.Fields = new ArrayList<GridFieldVO>();
String sql = GridFieldVO.getSQL(mTabVO.ctx);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, mTabVO.AD_Tab_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
GridFieldVO voF = GridFieldVO.create (mTabVO.ctx,
@ -299,16 +301,18 @@ public class GridTabVO implements Evaluatee, Serializable
if (voF != null)
mTabVO.Fields.add(voF);
}
rs.close();
pstmt.close();
}
catch (Exception e)
{
CLogger.get().log(Level.SEVERE, "", e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
mTabVO.initFields = true;

View File

@ -112,11 +112,13 @@ public class GridWorkbench implements Serializable
+ " AND w.AD_Workbench_ID=t.AD_Workbench_ID"
+ " AND t.AD_Language='" + Env.getAD_Language(m_ctx) + "'"
+ " AND w.AD_Column_ID=c.AD_Column_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Workbench_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
Name = rs.getString(1);
@ -135,13 +137,17 @@ public class GridWorkbench implements Serializable
}
else
AD_Workbench_ID = 0;
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (AD_Workbench_ID == 0)
return false;
@ -268,11 +274,13 @@ public class GridWorkbench implements Serializable
+ "FROM AD_WorkbenchWindow "
+ "WHERE AD_Workbench_ID=? AND IsActive='Y'"
+ "ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Workbench_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
int AD_Window_ID = rs.getInt(1);
@ -289,14 +297,18 @@ public class GridWorkbench implements Serializable
else if (AD_Task_ID > 0)
m_windows.add (new WBWindow(TYPE_TASK, AD_Task_ID));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return true;
} // initWorkbenchWindows

View File

@ -52,29 +52,25 @@ public class MArchive extends X_AD_Archive {
*/
public static MArchive[] get(Properties ctx, String whereClause) {
ArrayList<MArchive> list = new ArrayList<MArchive>();
PreparedStatement pstmt = null;
StringBuilder sql = new StringBuilder("SELECT * FROM AD_Archive WHERE AD_Client_ID=?");
if (whereClause != null && whereClause.length() > 0)
sql.append(whereClause);
sql.append(" ORDER BY Created");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, Env.getAD_Client_ID(ctx));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MArchive(ctx, rs, null));
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
s_log.log(Level.SEVERE, sql.toString(), e);
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (list.size() == 0)
@ -206,23 +202,20 @@ public class MArchive extends X_AD_Archive {
String name = "?";
String sql = "SELECT Name FROM AD_User WHERE AD_User_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getCreatedBy());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
name = rs.getString(1);
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return name;

View File

@ -71,37 +71,31 @@ public class MBPGroup extends X_C_BP_Group
if (retValue != null)
return retValue;
PreparedStatement pstmt = null;
String sql = "SELECT * FROM C_BP_Group g "
+ "WHERE IsDefault='Y' AND AD_Client_ID=? "
+ "ORDER BY IsActive DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
retValue = new MBPGroup (ctx, rs, null);
if (retValue.get_ID () != 0)
s_cacheDefault.put (key, retValue);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue == null)
@ -119,6 +113,7 @@ public class MBPGroup extends X_C_BP_Group
{
MBPGroup retValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM C_BP_Group g "
+ "WHERE EXISTS (SELECT * FROM C_BPartner p "
+ "WHERE p.C_BPartner_ID=? AND p.C_BP_Group_ID=g.C_BP_Group_ID)";
@ -126,7 +121,7 @@ public class MBPGroup extends X_C_BP_Group
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
retValue = new MBPGroup (ctx, rs, null);
@ -134,22 +129,15 @@ public class MBPGroup extends X_C_BP_Group
if (retValue.get_ID () != 0)
s_cache.put (key, retValue);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -150,29 +150,23 @@ public class MBPartner extends X_C_BPartner
+ " INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) "
+ "WHERE o.IsSOTrx='Y' AND Bill_BPartner_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getBigDecimal(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
@ -314,11 +308,12 @@ public class MBPartner extends X_C_BPartner
String sql = "SELECT * FROM C_BPartner "
+ "WHERE C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
success = load (rs);
else
@ -327,9 +322,6 @@ public class MBPartner extends X_C_BPartner
success = false;
log.severe ("None found");
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
@ -337,13 +329,8 @@ public class MBPartner extends X_C_BPartner
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
setStandardDefaults();
@ -492,16 +479,14 @@ public class MBPartner extends X_C_BPartner
ArrayList<MBPBankAccount> list = new ArrayList<MBPBankAccount>();
String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_BPartner_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MBPBankAccount (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
@ -509,13 +494,8 @@ public class MBPartner extends X_C_BPartner
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
@ -689,32 +669,26 @@ public class MBPartner extends X_C_BPartner
+ "FROM C_BPartner bp "
+ "WHERE C_BPartner_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_BPartner_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
SO_CreditUsed = rs.getBigDecimal(1);
TotalOpenBalance = rs.getBigDecimal(2);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
@ -739,29 +713,23 @@ public class MBPartner extends X_C_BPartner
+ "FROM C_BPartner bp "
+ "WHERE C_BPartner_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_BPartner_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
ActualLifeTimeValue = rs.getBigDecimal(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (ActualLifeTimeValue != null)

View File

@ -100,6 +100,7 @@ public class MBPartnerInfo extends X_RV_BPartner
"RV_BPartner", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
ArrayList<MBPartnerInfo> list = new ArrayList<MBPartnerInfo>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(finalSQL, null);
@ -116,25 +117,18 @@ public class MBPartnerInfo extends X_RV_BPartner
pstmt.setString(index++, Phone);
if (City != null)
pstmt.setString(index++, City);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MBPartnerInfo (ctx, rs, null));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "find - " + finalSQL, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Return

View File

@ -94,23 +94,29 @@ public class MBankAccountProcessor extends X_C_BankAccount_Processor {
sql.append(" AND bap.AcceptCORPORATE='Y'");
sql.append(" ORDER BY ba.IsDefault DESC ");
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), trxName);
pstmt = DB.prepareStatement(sql.toString(), trxName);
pstmt.setInt(1, AD_Client_ID);
pstmt.setInt(2, C_Currency_ID);
pstmt.setBigDecimal(3, Amt);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MBankAccountProcessor (ctx, rs, trxName));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, "find - " + sql, e);
return null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
if (list.size() == 0)
s_log.warning("find - not found - AD_Client_ID=" + AD_Client_ID

View File

@ -55,28 +55,22 @@ public class MBankStatementMatcher extends X_C_BankStatementMatcher
@SuppressWarnings("unused")
int AD_Client_ID = Env.getAD_Client_ID(ctx);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add (new MBankStatementMatcher(ctx, rs, trxName));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Convert

View File

@ -48,33 +48,27 @@ public class MCStage extends X_CM_CStage
public static MCStage[] getStages (MWebProject project)
{
ArrayList<MCStage> list = new ArrayList<MCStage>();
PreparedStatement pstmt = null;
String sql = "SELECT * FROM CM_CStage WHERE CM_WebProject_ID=? ORDER BY CM_CStage_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, project.get_TrxName());
pstmt.setInt (1, project.getCM_WebProject_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MCStage (project.getCtx(), rs, project.get_TrxName()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MCStage[] retValue = new MCStage[list.size ()];

View File

@ -118,9 +118,6 @@ public class MCashPlan extends X_C_CashPlan
MCashPlanLine il = new MCashPlanLine(getCtx(), rs, get_TrxName());
list.add(il);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{

View File

@ -52,31 +52,25 @@ public class MClick extends X_W_Click
ArrayList<MClick> list = new ArrayList<MClick> ();
String sql = "SELECT * FROM W_Click WHERE AD_Client_ID=? AND Processed = 'N'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MClick (ctx, rs, null));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
@ -199,12 +193,13 @@ public class MClick extends X_W_Click
int W_ClickCount_ID = 0;
int exactW_ClickCount_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
StringBuilder msgstr = new StringBuilder("%").append(url).append("%");
pstmt.setString(1, msgstr.toString());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
W_ClickCount_ID = rs.getInt(1);
@ -214,23 +209,17 @@ public class MClick extends X_W_Click
break;
}
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
// Set Click Count
if (exactW_ClickCount_ID != 0)
W_ClickCount_ID = exactW_ClickCount_ID;

View File

@ -114,11 +114,12 @@ public class MClickCount extends X_W_ClickCount
.append("GROUP BY TRUNC(Created, '").append(DateFormat).append("')");
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, getW_ClickCount_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String value = m_dateFormat.format(rs.getTimestamp(1));
@ -126,23 +127,17 @@ public class MClickCount extends X_W_ClickCount
ValueNamePair pp = new ValueNamePair (value, name);
list.add(pp);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql.toString(), ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
ValueNamePair[] retValue = new ValueNamePair[list.size()];
list.toArray(retValue);

View File

@ -303,10 +303,12 @@ public class MClient extends X_AD_Client
AD_Tree_Campaign_ID=0, AD_Tree_Activity_ID=0;
boolean success = false;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
PreparedStatement stmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = stmt.executeQuery();
stmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = stmt.executeQuery();
MTree_Base tree = null;
while (rs.next())
{
@ -374,13 +376,17 @@ public class MClient extends X_AD_Client
break;
}
}
rs.close();
stmt.close();
}
catch (SQLException e1)
{
log.log(Level.SEVERE, "Trees", e1);
success = false;
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
if (!success)

View File

@ -68,34 +68,29 @@ public class MClientInfo extends X_AD_ClientInfo
//
String sql = "SELECT * FROM AD_ClientInfo WHERE AD_Client_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
info = new MClientInfo (ctx, rs, null);
if (trxName == null)
s_cache.put (key, info);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
return info;
} // get

View File

@ -80,10 +80,11 @@ public class MClientShare extends X_AD_ClientShare
String sql = "SELECT AD_Client_ID, AD_Table_ID, ShareType "
+ "FROM AD_ClientShare WHERE ShareType<>'x' AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
int Client_ID = rs.getInt(1);
@ -95,22 +96,15 @@ public class MClientShare extends X_AD_ClientShare
else if (ShareType.equals(SHARETYPE_OrgNotShared))
s_shares.put(key.toString(), Boolean.FALSE);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (s_shares.isEmpty()) // put in something
@ -249,11 +243,12 @@ public class MClientShare extends X_AD_ClientShare
+ " AND c.ColumnName IN (SELECT ColumnName FROM AD_Column cc "
+ "WHERE cc.IsKey='Y' AND cc.AD_Table_ID=?))";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_Table_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
//int AD_Table_ID = rs.getInt(1);
@ -262,22 +257,15 @@ public class MClientShare extends X_AD_ClientShare
info.append(", ");
info.append(TableName);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.info(info.toString());

View File

@ -558,22 +558,28 @@ public class MColumn extends X_AD_Column
int retValue = 0;
String SQL = "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID = ? AND columnname = ?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_table_id);
pstmt.setString(2, columnName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, SQL, e);
retValue = -1;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
}
//end vpj-cd e-evolution

View File

@ -126,11 +126,12 @@ public class MColumnAccess extends X_AD_Column_Access
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID) "
+ "WHERE AD_Column_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getAD_Column_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_tableName = rs.getString(1);
@ -138,22 +139,15 @@ public class MColumnAccess extends X_AD_Column_Access
if (rs.getInt(3) != getAD_Table_ID())
log.log(Level.SEVERE, "AD_Table_ID inconsistent - Access=" + getAD_Table_ID() + " - Table=" + rs.getInt(3));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Get Clear Text

View File

@ -226,6 +226,7 @@ public class MConversionRate extends X_C_Conversion_Rate
+ "ORDER BY AD_Client_ID DESC, AD_Org_ID DESC, ValidFrom DESC";
BigDecimal retValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
@ -235,27 +236,20 @@ public class MConversionRate extends X_C_Conversion_Rate
pstmt.setTimestamp(4, ConvDate);
pstmt.setInt(5, AD_Client_ID);
pstmt.setInt(6, AD_Org_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getBigDecimal(1);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getRate", e);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
}
if (retValue == null)
s_log.info ("getRate - not found - CurFrom=" + CurFrom_ID
+ ", CurTo=" + CurTo_ID

View File

@ -63,6 +63,7 @@ public class MCostQueue extends X_M_CostQueue
+ " AND M_CostType_ID=? AND C_AcctSchema_ID=?"
+ " AND M_CostElement_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
@ -73,25 +74,18 @@ public class MCostQueue extends X_M_CostQueue
pstmt.setInt (5, as.getM_CostType_ID());
pstmt.setInt (6, as.getC_AcctSchema_ID());
pstmt.setInt (7, M_CostElement_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
costQ = new MCostQueue (product.getCtx(), rs, trxName);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// New
@ -127,6 +121,7 @@ public class MCostQueue extends X_M_CostQueue
if (!ce.isFifo())
sql.append("DESC");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), trxName);
@ -138,25 +133,18 @@ public class MCostQueue extends X_M_CostQueue
pstmt.setInt (6, ce.getM_CostElement_ID());
if (M_ASI_ID != 0)
pstmt.setInt (7, M_ASI_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MCostQueue (product.getCtx(), rs, trxName));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql.toString(), e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MCostQueue[] costQ = new MCostQueue[list.size()];

View File

@ -113,10 +113,12 @@ public final class MCountry extends X_C_Country
//
s_countries = new CCache<String,MCountry>(Table_Name, 250);
String sql = "SELECT * FROM C_Country WHERE IsActive='Y'";
Statement stmt = null;
ResultSet rs = null;
try
{
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
MCountry c = new MCountry (ctx, rs, null);
@ -127,13 +129,17 @@ public final class MCountry extends X_C_Country
if (c.getC_Country_ID() == COUNTRY_US) // USA
usa = c;
}
rs.close();
stmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
if (s_default == null)
s_default = usa;
s_log.fine("#" + s_countries.size()

View File

@ -85,11 +85,13 @@ public class MDesktop
.append("WHERE w.AD_Desktop_ID=? AND w.IsActive='Y'")
.append(" AND w.AD_Desktop_ID=t.AD_Desktop_ID")
.append(" AND t.AD_Language='").append(Env.getAD_Language(m_ctx)).append("'");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, AD_Desktop_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
Name = rs.getString(1);
@ -107,13 +109,17 @@ public class MDesktop
}
else
AD_Desktop_ID = 0;
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (AD_Desktop_ID == 0)
return false;
@ -207,24 +213,30 @@ public class MDesktop
+ "FROM AD_DesktopWorkbench "
+ "WHERE AD_Desktop_ID=? AND IsActive='Y' "
+ "ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Desktop_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
int AD_Workbench_ID = rs.getInt(1);
m_workbenches.add (new Integer(AD_Workbench_ID));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "MWorkbench.initDesktopWorkbenches", e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return true;
} // initDesktopWorkbenches

View File

@ -115,29 +115,23 @@ public class MDiscountSchema extends X_M_DiscountSchema
String sql = "SELECT * FROM M_DiscountSchemaBreak WHERE M_DiscountSchema_ID=? ORDER BY SeqNo";
ArrayList<MDiscountSchemaBreak> list = new ArrayList<MDiscountSchemaBreak>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_DiscountSchema_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MDiscountSchemaBreak(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_breaks = new MDiscountSchemaBreak[list.size ()];
@ -160,29 +154,23 @@ public class MDiscountSchema extends X_M_DiscountSchema
String sql = "SELECT * FROM M_DiscountSchemaLine WHERE M_DiscountSchema_ID=? ORDER BY SeqNo";
ArrayList<MDiscountSchemaLine> list = new ArrayList<MDiscountSchemaLine>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_DiscountSchema_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MDiscountSchemaLine(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_lines = new MDiscountSchemaLine[list.size ()];

View File

@ -73,11 +73,12 @@ public class MDistributionList extends X_M_DistributionList
//
String sql = "SELECT * FROM M_DistributionListLine WHERE M_DistributionList_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_DistributionList_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MDistributionListLine line = new MDistributionListLine(getCtx(), rs, get_TrxName());
@ -86,22 +87,15 @@ public class MDistributionList extends X_M_DistributionList
if (ratio != null)
ratioTotal = ratioTotal.add(ratio);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getLines", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Update Ratio

View File

@ -79,29 +79,23 @@ public class MDistributionRun extends X_M_DistributionRun
+ "WHERE M_DistributionRun_ID=? AND IsActive='Y' AND TotalQty IS NOT NULL AND TotalQty<> 0 ORDER BY Line";
ArrayList<MDistributionRunLine> list = new ArrayList<MDistributionRunLine>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_DistributionRun_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MDistributionRunLine(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_lines = new MDistributionRunLine[list.size()];

View File

@ -58,29 +58,23 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail
else
sql.append("ORDER BY M_DistributionRunLine_ID");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), trxName);
pstmt.setInt (1, M_DistributionRun_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MDistributionRunDetail(ctx, rs, trxName));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql.toString(), e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MDistributionRunDetail[] retValue = new MDistributionRunDetail[list.size()];

View File

@ -99,11 +99,12 @@ public class MDocTypeCounter extends X_C_DocTypeCounter
MDocTypeCounter temp = null;
String sql = "SELECT * FROM C_DocTypeCounter WHERE C_DocType_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, C_DocType_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next () && retValue == null)
{
retValue = new MDocTypeCounter (ctx, rs, null);
@ -113,22 +114,15 @@ public class MDocTypeCounter extends X_C_DocTypeCounter
retValue = null;
}
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getCounterDocType", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue != null) // valid

View File

@ -88,31 +88,25 @@ public class MDunningLevel extends X_C_DunningLevel
ArrayList<MDunningLevel> list = new ArrayList<MDunningLevel>();
String sql = "SELECT * FROM C_DunningLevel WHERE C_Dunning_ID=? AND DaysAfterDue+DaysBetweenDunning<?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getParent().get_ID ());
int totalDays = getDaysAfterDue ().intValue ()+getDaysBetweenDunning ();
pstmt.setInt(2, totalDays);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MDunningLevel(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -133,33 +133,27 @@ public class MDunningRun extends X_C_DunningRun
String sql = "SELECT * FROM C_DunningRunEntry WHERE C_DunningRun_ID=? ORDER BY C_DunningLevel_ID, C_DunningRunEntry_ID";
ArrayList<MDunningRunEntry> list = new ArrayList<MDunningRunEntry>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_DunningRun_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MDunningRunEntry thisEntry = new MDunningRunEntry(getCtx(), rs, get_TrxName());
if (!(onlyInvoices && thisEntry.hasInvoices()))
list.add (new MDunningRunEntry(getCtx(), rs, get_TrxName()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_entries = new MDunningRunEntry[list.size ()];

View File

@ -204,29 +204,23 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
if (onlyInvoices)
sql.append(" AND C_Invoice_ID IS NOT NULL");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, get_ID ());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MDunningRunLine(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql.toString(), e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
@ -245,34 +239,28 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
boolean retValue = false;
String sql = "SELECT COUNT(*) FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=? AND C_Invoice_ID IS NOT NULL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, get_ID ());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
if (rs.getInt(1) > 0)
retValue = true;
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
return retValue;
} // hasInvoices

View File

@ -78,25 +78,22 @@ public class MEXPFormatLine extends X_EXP_FormatLine {
.append(" AND ").append(X_EXP_Format.COLUMNNAME_EXP_Format_ID).append(" = ?")
;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement (sql.toString(), trxName);
pstmt.setString(1, value);
pstmt.setInt(2, EXP_Format_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if ( rs.next() ) {
result = new MEXPFormatLine (ctx, rs, trxName);
}
rs.close ();
pstmt.close ();
pstmt = null;
} catch (SQLException e) {
s_log.log(Level.SEVERE, sql.toString(), e);
throw e;
} finally {
try {
if (pstmt != null) pstmt.close ();
pstmt = null;
} catch (Exception e) { pstmt = null; }
} finally{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return result;

View File

@ -84,27 +84,24 @@ public class MEXPProcessor extends X_EXP_Processor {
.append(" AND IsActive = ?") // # 2
//.append(" ORDER BY ").append(X_EXP_ProcessorParameter.COLUMNNAME_)
;
PreparedStatement pstmt = null;
X_EXP_ProcessorParameter processorParameter = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement (sql.toString(), trxName);
pstmt.setInt(1, getEXP_Processor_ID());
pstmt.setString(2, "Y");
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while ( rs.next() ) {
processorParameter = new X_EXP_ProcessorParameter (getCtx(), rs, trxName);
resultList.add(processorParameter);
}
rs.close ();
pstmt.close ();
pstmt = null;
} catch (SQLException e) {
s_log.log(Level.SEVERE, sql.toString(), e);
} finally {
try {
if (pstmt != null) pstmt.close ();
pstmt = null;
} catch (Exception e) { pstmt = null; }
} finally{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
X_EXP_ProcessorParameter[] result = (X_EXP_ProcessorParameter[])resultList.toArray( new X_EXP_ProcessorParameter[0]);
parameters = result;

View File

@ -70,11 +70,12 @@ public class MGLCategory extends X_GL_Category
String sql = "SELECT * FROM GL_Category "
+ "WHERE AD_Client_ID=? AND IsDefault='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MGLCategory temp = new MGLCategory (ctx, rs, null);
@ -86,22 +87,15 @@ public class MGLCategory extends X_GL_Category
if (retValue == null)
retValue = temp;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;

View File

@ -96,29 +96,23 @@ public class MIMPProcessor
+ "WHERE " + X_IMP_Processor.COLUMNNAME_IMP_Processor_ID + "=? " // # 1
+ "ORDER BY Created DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getIMP_Processor_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MIMPProcessorLog (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MIMPProcessorLog[] retValue = new MIMPProcessorLog[list.size ()];
@ -156,26 +150,23 @@ public class MIMPProcessor
//.append(" ORDER BY ").append(X_EXP_ProcessorParameter.COLUMNNAME_)
;
PreparedStatement pstmt = null;
ResultSet rs = null;
X_IMP_ProcessorParameter processorParameter = null;
try {
pstmt = DB.prepareStatement (sql.toString(), trxName);
pstmt.setInt(1, getIMP_Processor_ID());
pstmt.setString(2, "Y");
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while ( rs.next() ) {
processorParameter = new X_IMP_ProcessorParameter (getCtx(), rs, trxName);
resultList.add(processorParameter);
}
rs.close ();
pstmt.close ();
pstmt = null;
} catch (SQLException e) {
s_log.log(Level.SEVERE, sql.toString(), e);
} finally {
try {
if (pstmt != null) pstmt.close ();
pstmt = null;
} catch (Exception e) { pstmt = null; }
} finally{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
X_IMP_ProcessorParameter[] result = (X_IMP_ProcessorParameter[])resultList.toArray( new X_IMP_ProcessorParameter[0]);
return result;
@ -186,28 +177,23 @@ public class MIMPProcessor
ArrayList<MIMPProcessor> list = new ArrayList<MIMPProcessor>();
String sql = "SELECT * FROM "+X_IMP_Processor.Table_Name+" WHERE IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MIMPProcessor (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -54,31 +54,25 @@ public class MInterestArea extends X_R_InterestArea
ArrayList<MInterestArea> list = new ArrayList<MInterestArea>();
String sql = "SELECT * FROM R_InterestArea WHERE IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MInterestArea ia = new MInterestArea (ctx, rs, null);
list.add (ia);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MInterestArea[] retValue = new MInterestArea[list.size ()];

View File

@ -1112,9 +1112,6 @@ public class MInvoice extends X_C_Invoice implements DocAction
{
retValue = rs.getBigDecimal(1);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException e)
{

View File

@ -93,31 +93,25 @@ public class MInvoiceBatch extends X_C_InvoiceBatch
String sql = "SELECT * FROM C_InvoiceBatchLine WHERE C_InvoiceBatch_ID=? ORDER BY Line";
ArrayList<MInvoiceBatchLine> list = new ArrayList<MInvoiceBatchLine>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_InvoiceBatch_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MInvoiceBatchLine (getCtx(), rs, get_TrxName()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -726,16 +726,14 @@ public class MInvoiceLine extends X_C_InvoiceLine
+ " LEFT OUTER JOIN C_Charge C ON (il.C_Charge_ID=c.C_Charge_ID) "
+ "WHERE C_InvoiceLine_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_InvoiceLine_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
m_name = rs.getString(1);
rs.close();
pstmt.close();
pstmt = null;
if (m_name == null)
m_name = "??";
}
@ -745,13 +743,8 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
@ -1238,19 +1231,17 @@ public class MInvoiceLine extends X_C_InvoiceLine
if (whereClause != null)
sql += whereClause;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_InvoiceLine_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
MLandedCost lc = new MLandedCost(getCtx(), rs, get_TrxName());
list.add(lc);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
@ -1258,13 +1249,8 @@ public class MInvoiceLine extends X_C_InvoiceLine
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -63,6 +63,7 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
//
ArrayList<MInvoicePaySchedule> list = new ArrayList<MInvoicePaySchedule>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), trxName);
@ -70,27 +71,20 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule
pstmt.setInt(1, C_Invoice_ID);
else
pstmt.setInt(1, C_InvoicePaySchedule_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
list.add (new MInvoicePaySchedule(ctx, rs, trxName));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getInvoicePaySchedule", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -50,29 +50,23 @@ public class MIssueProject extends X_R_IssueProject
MIssueProject pj = null;
String sql = "SELECT * FROM R_IssueProject WHERE Name=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setString (1, issue.getName());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
pj = new MIssueProject(issue.getCtx(), rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// New

View File

@ -47,31 +47,25 @@ public class MIssueSystem extends X_R_IssueSystem
if (issue.getDBAddress() == null)
return null;
MIssueSystem system = null;
PreparedStatement pstmt = null;
String sql = "SELECT * FROM R_IssueSystem WHERE DBAddress=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setString (1, issue.getDBAddress());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
system = new MIssueSystem(issue.getCtx(), rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// New

View File

@ -50,29 +50,23 @@ public class MIssueUser extends X_R_IssueUser
// Find Issue User
String sql = "SELECT * FROM R_IssueUser WHERE UserName=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setString (1, issue.getUserName());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
user = new MIssueUser (issue.getCtx(), rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -195,30 +195,25 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
ArrayList<MJournal> list = new ArrayList<MJournal>();
String sql = "SELECT * FROM GL_Journal WHERE GL_JournalBatch_ID=? ORDER BY DocumentNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getGL_JournalBatch_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MJournal (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
MJournal[] retValue = new MJournal[list.size()];
list.toArray(retValue);

View File

@ -49,31 +49,25 @@ public class MLandedCost extends X_C_LandedCost
ArrayList<MLandedCost> list = new ArrayList<MLandedCost> ();
String sql = "SELECT * FROM C_LandedCost WHERE C_InvoiceLine_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, il.get_TrxName());
pstmt.setInt (1, il.getC_InvoiceLine_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MLandedCost (il.getCtx(), rs, il.get_TrxName()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -53,29 +53,23 @@ public class MLandedCostAllocation extends X_C_LandedCostAllocation
ArrayList<MLandedCostAllocation> list = new ArrayList<MLandedCostAllocation>();
String sql = "SELECT * FROM C_LandedCostAllocation WHERE C_InvoiceLine_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, C_InvoiceLine_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MLandedCostAllocation (ctx, rs, trxName));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MLandedCostAllocation[] retValue = new MLandedCostAllocation[list.size ()];

View File

@ -101,21 +101,27 @@ public class MLocation extends X_C_Location implements Comparator<Object>
MLocation loc = null;
String sql = "SELECT * FROM C_Location l "
+ "WHERE C_Location_ID IN (SELECT C_Location_ID FROM C_BPartner_Location WHERE C_BPartner_Location_ID=?)";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, C_BPartner_Location_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
loc = new MLocation (ctx, rs, trxName);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql + " - " + C_BPartner_Location_ID, e);
loc = null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return loc;
} // getBPLocation

View File

@ -485,15 +485,17 @@ public final class MLookup extends Lookup implements Serializable
log.finer(m_info.KeyColumn + ": " + key
+ ", SaveInCache=" + saveInCache + ",Local=" + cacheLocal);
boolean isNumber = m_info.KeyColumn.endsWith("_ID");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
// SELECT Key, Value, Name FROM ...
PreparedStatement pstmt = DB.prepareStatement(m_info.QueryDirect, null);
pstmt = DB.prepareStatement(m_info.QueryDirect, null);
if (isNumber)
pstmt.setInt(1, Integer.parseInt(key.toString()));
else
pstmt.setString(1, key.toString());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
String name = rs.getString(3);
@ -523,8 +525,6 @@ public final class MLookup extends Lookup implements Serializable
directValue = null;
}
rs.close();
pstmt.close();
if (CLogMgt.isLevelFinest())
log.finest(m_info.KeyColumn + ": " + directValue + " - " + m_info);
}
@ -533,6 +533,12 @@ public final class MLookup extends Lookup implements Serializable
log.log(Level.SEVERE, m_info.KeyColumn + ": SQL=" + m_info.QueryDirect + "; Key=" + key, e);
directValue = null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Cache Local if not added to R/W cache
if (cacheLocal && !saveInCache && directValue != null)
{

View File

@ -46,11 +46,13 @@ public class MLookupInfo implements Serializable, Cloneable
int retValue = 0;
String sql = "SELECT AD_Reference_ID,Name,ValidationType,IsActive "
+ "FROM AD_Reference WHERE Name LIKE ?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, referenceName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
int i = 0;
int id = 0;
@ -69,13 +71,17 @@ public class MLookupInfo implements Serializable, Cloneable
"AD_Reference Name=").append(refName).append(", ID=").append(id).append(", Type=").append(validationType).append(", Active=").append(isActive);
CLogger.get().config(msgconf.toString());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
CLogger.get().log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // getAD_Reference_ID
@ -92,11 +98,13 @@ public class MLookupInfo implements Serializable, Cloneable
String sql = "SELECT c.AD_Column_ID,c.ColumnName,t.TableName "
+ "FROM AD_Column c, AD_Table t "
+ "WHERE c.ColumnName LIKE ? AND c.AD_Table_ID=t.AD_Table_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, columnName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
int i = 0;
int id = 0;
@ -112,13 +120,17 @@ public class MLookupInfo implements Serializable, Cloneable
StringBuilder msgconf = new StringBuilder("Name=").append(colName).append(", ID=").append(id).append(", Table=").append(tabName);
CLogger.get().config(msgconf.toString());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
CLogger.get().log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // getAD_Column_ID

View File

@ -339,13 +339,14 @@ public class MMailText extends X_R_MailText
{
MMailTextTrl trl = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM R_MailText_Trl WHERE R_MailText_ID=? AND AD_Language=?";
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getR_MailText_ID());
pstmt.setString(2, AD_Language);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next())
{
trl = new MMailTextTrl();
@ -355,24 +356,18 @@ public class MMailText extends X_R_MailText
trl.MailText2 = rs.getString("MailText2");
trl.MailText3 = rs.getString("MailText3");
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return trl;
} // getTranslation

View File

@ -238,10 +238,11 @@ public class MMeasureCalc extends X_PA_MeasureCalc
// Execute
StringBuilder where = new StringBuilder();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (finalSQL, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
int id = rs.getInt(1);
@ -249,22 +250,15 @@ public class MMeasureCalc extends X_PA_MeasureCalc
where.append(",");
where.append(id);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, finalSQL, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (where.length() == 0)

View File

@ -50,32 +50,26 @@ public class MMedia extends X_CM_Media
{
ArrayList<MMedia> list = new ArrayList<MMedia>();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM CM_Media WHERE CM_WebProject_ID=? ORDER BY CM_Media_ID";
try
{
pstmt = DB.prepareStatement (sql, project.get_TrxName());
pstmt.setInt (1, project.getCM_WebProject_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MMedia (project.getCtx(), rs, project.get_TrxName()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MMedia[] retValue = new MMedia[list.size ()];

View File

@ -54,29 +54,23 @@ public class MMessage extends X_AD_Message
{
String sql = "SELECT * FROM AD_Message WHERE Value=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, Value);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = new MMessage (ctx, rs, null);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "get", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue != null)

View File

@ -146,29 +146,23 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
+ "WHERE M_MovementConfirm_ID=?";
ArrayList<MMovementLineConfirm> list = new ArrayList<MMovementLineConfirm>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_MovementConfirm_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MMovementLineConfirm(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_lines = new MMovementLineConfirm[list.size ()];

View File

@ -52,31 +52,25 @@ public class MMovementLineMA extends X_M_MovementLineMA
ArrayList<MMovementLineMA> list = new ArrayList<MMovementLineMA>();
String sql = "SELECT * FROM M_MovementLineMA WHERE M_MovementLine_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, M_MovementLine_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MMovementLineMA (ctx, rs, trxName));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -75,29 +75,23 @@ public class MNewsChannel extends X_CM_NewsChannel
sql += " AND " + where;
sql += " ORDER BY pubDate DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, this.get_TrxName());
pstmt.setInt (1, this.get_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MNewsItem(this.getCtx(), rs, this.get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MNewsItem[] retValue = new MNewsItem[list.size ()];

View File

@ -82,6 +82,7 @@ public class MOrderLine extends X_C_OrderLine
sql += " AND M_AttributeSetInstance_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
@ -90,25 +91,18 @@ public class MOrderLine extends X_C_OrderLine
pstmt.setInt (3, excludeC_OrderLine_ID);
if (M_AttributeSetInstance_ID != 0)
pstmt.setInt (4, M_AttributeSetInstance_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getBigDecimal(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue == null)

View File

@ -63,6 +63,7 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule
//
ArrayList<MOrderPaySchedule> list = new ArrayList<MOrderPaySchedule>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
@ -70,27 +71,20 @@ public class MOrderPaySchedule extends X_C_OrderPaySchedule
pstmt.setInt(1, C_Order_ID);
else
pstmt.setInt(1, C_OrderPaySchedule_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
list.add (new MOrderPaySchedule(ctx, rs, trxName));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "getOrderPaySchedule", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -77,30 +77,24 @@ public class MOrderTax extends X_C_OrderTax
String sql = "SELECT * FROM C_OrderTax WHERE C_Order_ID=? AND C_Tax_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, line.getC_Order_ID());
pstmt.setInt (2, C_Tax_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MOrderTax (line.getCtx(), rs, trxName);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue != null)
@ -212,12 +206,13 @@ public class MOrderTax extends X_C_OrderTax
//
String sql = "SELECT LineNetAmt FROM C_OrderLine WHERE C_Order_ID=? AND C_Tax_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_Order_ID());
pstmt.setInt (2, getC_Tax_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
BigDecimal baseAmt = rs.getBigDecimal(1);
@ -226,23 +221,16 @@ public class MOrderTax extends X_C_OrderTax
if (!documentLevel) // calculate line tax
taxAmt = taxAmt.add(tax.calculateTax(baseAmt, isTaxIncluded(), getPrecision()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, get_TrxName(), e);
taxBaseAmt = null;
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -152,18 +152,16 @@ public class MPInstance extends X_AD_PInstance
m_log.clear();
String sql = "SELECT * FROM AD_PInstance_Log WHERE AD_PInstance_ID=? ORDER BY Log_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
m_log.add(new MPInstanceLog(rs));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
@ -171,16 +169,10 @@ public class MPInstance extends X_AD_PInstance
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MPInstanceLog[] retValue = new MPInstanceLog[m_log.size()];
m_log.toArray(retValue);
return retValue;

View File

@ -97,29 +97,23 @@ public class MPOSKeyLayout extends X_C_POSKeyLayout
ArrayList<MPOSKey> list = new ArrayList<MPOSKey>();
String sql = "SELECT * FROM C_POSKey WHERE C_POSKeyLayout_ID=? AND IsActive = 'Y' ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_POSKeyLayout_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MPOSKey(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -57,11 +57,12 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
String sql = "SELECT * FROM C_PaySelectionCheck WHERE C_Payment_ID=?";
int count = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, C_Payment_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MPaySelectionCheck psc = new MPaySelectionCheck (ctx, rs, trxName);
@ -71,22 +72,15 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
retValue = psc;
count++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (count > 1)
@ -215,12 +209,14 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
int docNo = startDocumentNo;
String sql = "SELECT * FROM C_PaySelectionCheck "
+ "WHERE C_PaySelection_ID=? AND PaymentRule=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, trxName);
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, C_PaySelection_ID);
pstmt.setString(2, PaymentRule);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
MPaySelectionCheck check = new MPaySelectionCheck (Env.getCtx(), rs, trxName);
@ -229,14 +225,17 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
check.saveEx();
list.add(check);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// convert to Array
MPaySelectionCheck[] retValue = new MPaySelectionCheck[list.size()];
list.toArray(retValue);
@ -543,29 +542,23 @@ public final class MPaySelectionCheck extends X_C_PaySelectionCheck
ArrayList<MPaySelectionLine> list = new ArrayList<MPaySelectionLine>();
String sql = "SELECT * FROM C_PaySelectionLine WHERE C_PaySelectionCheck_ID=? ORDER BY Line";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_PaySelectionCheck_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MPaySelectionLine(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -2283,8 +2283,6 @@ public final class MPayment extends X_C_Payment
if (alloc.get_ID() == 0 && !alloc.save(get_TrxName()))
{
log.log(Level.SEVERE, "Could not create Allocation Hdr");
rs.close();
pstmt.close();
return false;
}
MAllocationLine aLine = null;

View File

@ -142,9 +142,6 @@ public class MPaymentLookup extends Lookup implements Serializable {
rs = pstmt.executeQuery();
while (rs.next())
list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException e)
{

View File

@ -96,33 +96,27 @@ public class MPaymentTerm extends X_C_PaymentTerm
String sql = "SELECT * FROM C_PaySchedule WHERE C_PaymentTerm_ID=? AND IsActive='Y' ORDER BY NetDays";
ArrayList<MPaySchedule> list = new ArrayList<MPaySchedule>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_PaymentTerm_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
MPaySchedule ps = new MPaySchedule(getCtx(), rs, get_TrxName());
ps.setParent(this);
list.add (ps);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getSchedule", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -48,33 +48,27 @@ public class MPrivateAccess extends X_AD_Private_Access
public static MPrivateAccess get (Properties ctx, int AD_User_ID, int AD_Table_ID, int Record_ID)
{
MPrivateAccess retValue = null;
PreparedStatement pstmt = null;
String sql = "SELECT * FROM AD_Private_Access WHERE AD_User_ID=? AND AD_Table_ID=? AND Record_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_Table_ID);
pstmt.setInt(3, Record_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = new MPrivateAccess (ctx, rs, null);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "MPrivateAccess", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;

View File

@ -77,29 +77,23 @@ public class MProductCategory extends X_M_Product_Category
String sql = "SELECT M_Product_Category_ID FROM M_Product WHERE M_Product_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, M_Product_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
category = new Integer(rs.getInt(1));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (category != null)

View File

@ -58,10 +58,11 @@ public class MProductDownload extends X_M_ProductDownload
+ "FROM M_Product "
+ "WHERE DownloadURL IS NOT NULL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
int AD_Client_ID = rs.getInt(1);
@ -86,22 +87,15 @@ public class MProductDownload extends X_M_ProductDownload
else
s_log.warning("Product Download not created M_Product_ID=" + M_Product_ID);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
s_log.info("#" + count);

View File

@ -61,9 +61,6 @@ public class MProduction extends X_M_Production {
rs = pstmt.executeQuery();
while (rs.next())
list.add( new MProductionLine( getCtx(), rs.getInt(1), get_TrxName() ) );
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
@ -72,6 +69,8 @@ public class MProduction extends X_M_Production {
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MProductionLine[] retValue = new MProductionLine[list.size()];

View File

@ -113,30 +113,25 @@ public class MProjectPhase extends X_C_ProjectPhase
ArrayList<MProjectTask> list = new ArrayList<MProjectTask>();
String sql = "SELECT * FROM C_ProjectTask WHERE C_ProjectPhase_ID=? ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_ProjectPhase_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MProjectTask (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
MProjectTask[] retValue = new MProjectTask[list.size()];
list.toArray(retValue);

View File

@ -116,30 +116,25 @@ public class MProjectType extends X_C_ProjectType
ArrayList<MProjectTypePhase> list = new ArrayList<MProjectTypePhase>();
String sql = "SELECT * FROM C_Phase WHERE C_ProjectType_ID=? ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_ProjectType_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MProjectTypePhase (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
MProjectTypePhase[] retValue = new MProjectTypePhase[list.size()];
list.toArray(retValue);

View File

@ -78,30 +78,25 @@ public class MProjectTypePhase extends X_C_Phase
ArrayList<MProjectTypeTask> list = new ArrayList<MProjectTypeTask>();
String sql = "SELECT * FROM C_Task WHERE C_Phase_ID=? ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_Phase_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MProjectTypeTask (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
//
MProjectTypeTask[] retValue = new MProjectTypeTask[list.size()];
list.toArray(retValue);

View File

@ -72,30 +72,24 @@ public class MRMATax extends X_M_RMATax
String sql = "SELECT * FROM M_RMATax WHERE M_RMA_ID=? AND C_Tax_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, line.getM_RMA_ID());
pstmt.setInt (2, C_Tax_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MRMATax (line.getCtx(), rs, trxName);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (retValue != null)
@ -205,12 +199,13 @@ public class MRMATax extends X_M_RMATax
//
String sql = "SELECT LineNetAmt FROM M_RMALine WHERE M_RMA_ID=? AND C_Tax_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getM_RMA_ID());
pstmt.setInt (2, getC_Tax_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
BigDecimal baseAmt = rs.getBigDecimal(1);
@ -219,23 +214,16 @@ public class MRMATax extends X_M_RMATax
if (!documentLevel) // calculate line tax
taxAmt = taxAmt.add(tax.calculateTax(baseAmt, isTaxIncluded(), getPrecision()));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, get_TrxName(), e);
taxBaseAmt = null;
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -97,11 +97,12 @@ public class MRecordAccess extends X_AD_Record_Access
+ "FROM AD_Column "
+ "WHERE AD_Table_ID=? AND IsKey='Y' AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_Table_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String s = rs.getString(1);
@ -110,22 +111,15 @@ public class MRecordAccess extends X_AD_Record_Access
else
log.log(Level.SEVERE, "More than one key = " + s);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (m_keyColumnName == null)
@ -251,31 +245,25 @@ public class MRecordAccess extends X_AD_Record_Access
{
String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_Table_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_tableName = rs.getString(1);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Get Clear Text

View File

@ -155,9 +155,6 @@ public class MRefList extends X_AD_Ref_List
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getString(1);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
@ -213,9 +210,6 @@ public class MRefList extends X_AD_Ref_List
rs = pstmt.executeQuery();
while (rs.next())
list.add(new ValueNamePair(rs.getString(1), rs.getString(2)));
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException e)
{

View File

@ -57,10 +57,12 @@ public final class MRegion extends X_C_Region
{
s_regions = new CCache<String,MRegion>(Table_Name, 100);
String sql = "SELECT * FROM C_Region WHERE IsActive='Y'";
Statement stmt = null;
ResultSet rs = null;
try
{
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
MRegion r = new MRegion (ctx, rs, null);
@ -68,13 +70,17 @@ public final class MRegion extends X_C_Region
if (r.isDefault())
s_default = r;
}
rs.close();
stmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
s_log.fine(s_regions.size() + " - default=" + s_default);
} // loadAllRegions

View File

@ -125,29 +125,23 @@ public class MRegistration extends X_A_Registration
ArrayList<MRegistrationValue> list = new ArrayList<MRegistrationValue>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getA_Registration_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
list.add(new MRegistrationValue(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Convert and Sort
@ -171,32 +165,26 @@ public class MRegistration extends X_A_Registration
+ " AND NOT EXISTS (SELECT A_RegistrationAttribute_ID FROM A_RegistrationValue v "
+ "WHERE ra.A_RegistrationAttribute_ID=v.A_RegistrationAttribute_ID AND r.A_Registration_ID=v.A_Registration_ID)";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getA_Registration_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
MRegistrationValue v = new MRegistrationValue (this, rs.getInt(1), "?");
v.saveEx();
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, null, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // createMissingValues

View File

@ -55,11 +55,12 @@ public class MRegistrationAttribute extends X_A_RegistrationAttribute
+ "ORDER BY SeqNo";
int AD_Client_ID = Env.getAD_Client_ID(ctx);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
MRegistrationAttribute value = new MRegistrationAttribute(ctx, rs, null);
@ -67,22 +68,15 @@ public class MRegistrationAttribute extends X_A_RegistrationAttribute
s_cache.put(key, value);
list.add(value);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -51,28 +51,22 @@ public class MRequestProcessor extends X_R_RequestProcessor
ArrayList<MRequestProcessor> list = new ArrayList<MRequestProcessor>();
String sql = "SELECT * FROM R_RequestProcessor WHERE IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRequestProcessor (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MRequestProcessor[] retValue = new MRequestProcessor[list.size ()];
@ -146,29 +140,23 @@ public class MRequestProcessor extends X_R_RequestProcessor
String sql = "SELECT * FROM R_RequestProcessor_Route WHERE R_RequestProcessor_ID=? ORDER BY SeqNo";
ArrayList<MRequestProcessorRoute> list = new ArrayList<MRequestProcessorRoute>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getR_RequestProcessor_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRequestProcessorRoute (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
@ -189,29 +177,23 @@ public class MRequestProcessor extends X_R_RequestProcessor
+ "WHERE R_RequestProcessor_ID=? "
+ "ORDER BY Created DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getR_RequestProcessor_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRequestProcessorLog (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MRequestProcessorLog[] retValue = new MRequestProcessorLog[list.size ()];

View File

@ -158,11 +158,12 @@ public class MRequestType extends X_R_RequestType
//
+ "FROM R_RequestType x WHERE R_RequestType_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
m_openNo = rs.getInt(1);
@ -170,22 +171,15 @@ public class MRequestType extends X_R_RequestType
m_new30No = rs.getInt(3);
m_closed30No = rs.getInt(4);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
@ -251,29 +245,23 @@ public class MRequestType extends X_R_RequestType
//
ArrayList<MRequest> list = new ArrayList<MRequest>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRequest (getCtx(), rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -126,29 +126,23 @@ public class MRfQLine extends X_C_RfQLine
+ "WHERE C_RfQLine_ID=? AND IsActive='Y' "
+ "ORDER BY Qty";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQLine_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRfQLineQty (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Create Default (1)

View File

@ -127,12 +127,13 @@ public class MRfQLineQty extends X_C_RfQLineQty
{
ArrayList<MRfQResponseLineQty> list = new ArrayList<MRfQResponseLineQty>();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM C_RfQResponseLineQty WHERE C_RfQLineQty_ID=? AND IsActive='Y'";
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQLineQty_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MRfQResponseLineQty qty = new MRfQResponseLineQty(getCtx(), rs, get_TrxName());
@ -141,22 +142,15 @@ public class MRfQLineQty extends X_C_RfQLineQty
else
list.add (qty);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MRfQResponseLineQty[] retValue = new MRfQResponseLineQty[list.size ()];

View File

@ -171,29 +171,23 @@ public class MRfQResponse extends X_C_RfQResponse
String sql = "SELECT * FROM C_RfQResponseLine "
+ "WHERE C_RfQResponse_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQResponse_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MRfQResponseLine(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getLines", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -125,29 +125,23 @@ public class MRfQResponseLine extends X_C_RfQResponseLine
String sql = "SELECT * FROM C_RfQResponseLineQty "
+ "WHERE C_RfQResponseLine_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQResponseLine_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRfQResponseLineQty(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -70,29 +70,23 @@ public class MRfQTopic extends X_C_RfQ_Topic
String sql = "SELECT * FROM C_RfQ_TopicSubscriber "
+ "WHERE C_RfQ_Topic_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQ_Topic_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRfQTopicSubscriber (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getSubscribers", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -76,29 +76,23 @@ public class MRfQTopicSubscriber extends X_C_RfQ_TopicSubscriber
ArrayList<MRfQTopicSubscriberOnly> list = new ArrayList<MRfQTopicSubscriberOnly>();
String sql = "SELECT * FROM C_RfQ_TopicSubscriberOnly WHERE C_RfQ_TopicSubscriber_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getC_RfQ_TopicSubscriber_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MRfQTopicSubscriberOnly(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -84,29 +84,23 @@ public class MRoleOrgAccess extends X_AD_Role_OrgAccess
{
ArrayList<MRoleOrgAccess> list = new ArrayList<MRoleOrgAccess>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, id);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MRoleOrgAccess(ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "get", e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MRoleOrgAccess[] retValue = new MRoleOrgAccess[list.size ()];
@ -233,32 +227,26 @@ public class MRoleOrgAccess extends X_AD_Role_OrgAccess
+ "FROM AD_Client c INNER JOIN AD_Org o ON (c.AD_Client_ID=o.AD_Client_ID) "
+ "WHERE o.AD_Org_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_Org_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_clientName = rs.getString(1);
m_orgName = rs.getString(2);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "getClientName", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}

View File

@ -96,29 +96,23 @@ public class MSLACriteria extends X_PA_SLA_Criteria
+ "WHERE PA_SLA_Criteria_ID=?";
ArrayList<MSLAGoal> list = new ArrayList<MSLAGoal>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getPA_SLA_Criteria_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MSLAGoal(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MSLAGoal[] retValue = new MSLAGoal[list.size ()];

View File

@ -102,29 +102,23 @@ public class MSLAGoal extends X_PA_SLA_Goal
{
ArrayList<MSLAMeasure> list = new ArrayList<MSLAMeasure>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getPA_SLA_Goal_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MSLAMeasure(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
MSLAMeasure[] retValue = new MSLAMeasure[list.size ()];

View File

@ -81,30 +81,25 @@ public class MStatus extends X_R_Status
+ " AND IsDefault='Y' "
+ "ORDER BY SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt(1, R_RequestType_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MStatus (ctx, rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
if (retValue != null)
s_cacheDefault.put(key, retValue);
return retValue;
@ -123,30 +118,25 @@ public class MStatus extends X_R_Status
+ "ORDER BY Value";
ArrayList<MStatus> list = new ArrayList<MStatus>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add(new MStatus (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
MStatus[] retValue = new MStatus[list.size()];
list.toArray(retValue);
return retValue;

View File

@ -55,29 +55,23 @@ public class MStatusCategory extends X_R_StatusCategory
+ "ORDER BY AD_Client_ID DESC";
MStatusCategory retValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = new MStatusCategory (ctx, rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
@ -173,29 +167,23 @@ public class MStatusCategory extends X_R_StatusCategory
+ "ORDER BY SeqNo";
ArrayList<MStatus> list = new ArrayList<MStatus>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getR_StatusCategory_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MStatus (getCtx(), rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -81,30 +81,24 @@ public class MStore extends X_W_Store
// Search by context
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM W_Store WHERE WebContext=?";
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setString(1, contextPath);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
wstore = new MStore (ctx, rs, null);
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Try client
@ -115,29 +109,22 @@ public class MStore extends X_W_Store
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
{
wstore = new MStore (ctx, rs, null);
s_log.warning("Context " + contextPath
+ " Not found - Found via AD_Client_ID=" + Env.getAD_Client_ID(ctx));
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
@ -161,29 +148,23 @@ public class MStore extends X_W_Store
ArrayList<MStore> list = new ArrayList<MStore>();
String sql = "SELECT * FROM W_Store WHERE AD_Client_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, client.get_TrxName());
pstmt.setInt (1, client.getAD_Client_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MStore (client.getCtx(), rs, client.get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
@ -469,29 +450,23 @@ public class MStore extends X_W_Store
//
String sql = "SELECT * FROM W_MailMsg WHERE W_Store_ID=? ORDER BY MailMsgType";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getW_Store_ID());
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MMailMsg (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -248,12 +248,8 @@ public class ColumnElementHandler extends AbstractElementHandler {
// No existing column
sql = column.getSQLAdd(table);
}
rsc.close();
rsc = null;
}
rst.close();
rst = null;
//execute modify or add if needed
if (sql != null && sql.trim().length() > 0) {
log.info(sql);
@ -277,23 +273,16 @@ public class ColumnElementHandler extends AbstractElementHandler {
trx.commit(true);
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
if (rsc != null) {
try {
rsc.close();
} catch (SQLException e1) {
}
rsc = null;
}
if (rst != null) {
try {
rst.close();
} catch (SQLException e1) {
}
rst = null;
}
trx.rollback();
return 0;
}
finally
{
DB.close(rsc);
rsc = null;
DB.close(rst);
rst = null;
}
return 1;
}

View File

@ -196,18 +196,20 @@ public class VAttributeGrid extends CPanel
// Add Access & Order
sql = MRole.getDefault().addAccessSQL (sql, "M_PriceList_Version", true, false) // fully qualidfied - RO
+ " ORDER BY M_PriceList_Version.Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pickPriceList.addItem(new KeyNamePair (0, ""));
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair kn = new KeyNamePair (rs.getInt(1), rs.getString(2));
pickPriceList.addItem(kn);
}
rs.close();
pstmt.close();
DB.close(rs, pstmt);
rs = null;pstmt = null;
// Warehouse
sql = "SELECT M_Warehouse_ID, Value || ' - ' || Name AS ValueName "
@ -225,13 +227,17 @@ public class VAttributeGrid extends CPanel
(rs.getInt("M_Warehouse_ID"), rs.getString("ValueName"));
pickWarehouse.addItem(kn);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // fillPicks
@ -430,33 +436,27 @@ public class VAttributeGrid extends CPanel
sql = MRole.getDefault().addAccessSQL(sql, "M_Product",
MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
int noProducts = 0;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MProduct product = new MProduct(Env.getCtx(), rs, null);
addProduct (element, product);
noProducts++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -227,19 +227,25 @@ public class VLocatorDialog extends CDialog
String SQL = MRole.getDefault().addAccessSQL(
sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
+ " ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("Warehouses=" + fWarehouse.getItemCount());
// Load existing Locators

View File

@ -102,23 +102,29 @@ public abstract class CreateFromInvoice extends CreateFrom
+ "HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)"
+ " OR mi.M_InOutLine_ID IS NULL) "
+ "ORDER BY s.MovementDate");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_BPartner_ID);
pstmt.setInt(2, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}
@ -201,12 +207,13 @@ public abstract class CreateFromInvoice extends CreateFrom
+ "l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name), "
+ "l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID ")
.append("ORDER BY l.Line");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, M_InOut_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(7);
@ -230,13 +237,17 @@ public abstract class CreateFromInvoice extends CreateFrom
line.add(null); // 7-RMA
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
} // loadShipment
@ -310,7 +321,6 @@ public abstract class CreateFromInvoice extends CreateFrom
line.add(pp); //7-RMA
data.add(line);
}
rs.close();
}
catch (Exception ex)
{

View File

@ -159,13 +159,17 @@ public abstract class CreateFromShipment extends CreateFrom
{
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}

View File

@ -168,6 +168,8 @@ public class Translation
String[] trlColumns = getTrlColumns (Base_Table);
//
StringBuffer sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@ -214,10 +216,10 @@ public class Translation
sql.append(haveWhere ? " AND " : " WHERE ").append("o.AD_Client_ID=").append(AD_Client_ID);
sql.append(" ORDER BY t.").append(keyColumn);
//
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
if (!isBaseLanguage)
pstmt.setString(1, AD_Language);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
int rows = 0;
while (rs.next())
{
@ -245,8 +247,6 @@ public class Translation
root.appendChild(row);
rows++;
}
rs.close();
pstmt.close();
log.info("Records=" + rows
+ ", DTD=" + document.getDoctype()
+ " - " + Trl_Table);
@ -275,6 +275,12 @@ public class Translation
log.log(Level.SEVERE, "", e);
return e.toString();
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "";
} // exportTrl
@ -291,20 +297,26 @@ public class Translation
String sql = "SELECT TableName FROM AD_Table t"
+ " INNER JOIN AD_Column c ON (c.AD_Table_ID=t.AD_Table_ID AND c.ColumnName='IsCentrallyMaintained') "
+ "WHERE t.TableName=? AND c.IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, Base_Table);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
m_IsCentrallyMaintained = true;
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
sql = "SELECT ColumnName "
+ "FROM AD_Column c"
@ -316,23 +328,27 @@ public class Translation
ArrayList<String> list = new ArrayList<String>();
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, Base_Table + "_Trl");
pstmt.setString(2, PO.getUUIDColumnName(Base_Table + "_Trl"));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String s = rs.getString(1);
// System.out.println(s);
list.add(s);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Convert to Array
String[] retValue = new String[list.size()];
@ -354,21 +370,27 @@ public class Translation
+ "FROM AD_Language "
+ "WHERE AD_Language=?";
MLanguage language = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, AD_Language);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
language = new MLanguage (m_ctx, rs, null);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.toString();
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// No AD_Language Record
if (language == null)
@ -408,19 +430,25 @@ public class Translation
+ "WHERE TableName LIKE '%_Trl' "
+ "ORDER BY Name";
ArrayList<String> trlTables = new ArrayList<String>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
trlTables.add(rs.getString(2));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
for (int i = 0; i < trlTables.size(); i++)
{

Some files were not shown because too many files have changed in this diff Show More