IDEMPIERE-568 Review proper closing of JDBC statements and resultsets

This commit is contained in:
Richard Morales 2013-02-19 18:17:37 -05:00
parent cb10e71ad0
commit f737c1fc87
71 changed files with 866 additions and 866 deletions

View File

@ -90,9 +90,6 @@ public class CalloutGLJournal extends CalloutEngine
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
C_Period_ID = rs.getInt(1); C_Period_ID = rs.getInt(1);
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -102,6 +99,8 @@ public class CalloutGLJournal extends CalloutEngine
finally finally
{ {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
if (C_Period_ID != 0) if (C_Period_ID != 0)
mTab.setValue("C_Period_ID", new Integer(C_Period_ID)); mTab.setValue("C_Period_ID", new Integer(C_Period_ID));

View File

@ -155,15 +155,16 @@ public class CalloutInventory extends CalloutEngine
sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand " sql = "SELECT SUM(QtyOnHand) FROM M_StorageOnHand "
+ "WHERE M_Product_ID=?" // 1 + "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2 + " AND M_Locator_ID=?"; // 2
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID); pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_Locator_ID); pstmt.setInt(2, M_Locator_ID);
if (M_AttributeSetInstance_ID != 0) if (M_AttributeSetInstance_ID != 0)
pstmt.setInt(3, M_AttributeSetInstance_ID); pstmt.setInt(3, M_AttributeSetInstance_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
bd = rs.getBigDecimal(1); bd = rs.getBigDecimal(1);
@ -174,14 +175,19 @@ public class CalloutInventory extends CalloutEngine
// for example when the locator has never stored a particular product. // for example when the locator has never stored a particular product.
return new BigDecimal(0); return new BigDecimal(0);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
throw new Exception(e.getLocalizedMessage()); throw new Exception(e.getLocalizedMessage());
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return new BigDecimal(0); return new BigDecimal(0);
} }

View File

@ -88,24 +88,30 @@ public class CalloutRequest extends CalloutEngine
Integer R_StandardResponse_ID = (Integer)value; Integer R_StandardResponse_ID = (Integer)value;
String sql = "SELECT Name, ResponseText FROM R_StandardResponse " String sql = "SELECT Name, ResponseText FROM R_StandardResponse "
+ "WHERE R_StandardResponse_ID=?"; + "WHERE R_StandardResponse_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, R_StandardResponse_ID.intValue()); pstmt.setInt(1, R_StandardResponse_ID.intValue());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
String txt = rs.getString(2); String txt = rs.getString(2);
txt = Env.parseContext(ctx, WindowNo, txt, false, true); txt = Env.parseContext(ctx, WindowNo, txt, false, true);
mTab.setValue("Result", txt); mTab.setValue("Result", txt);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return ""; return "";
} // copyResponse } // copyResponse

View File

@ -81,6 +81,7 @@ public class ColumnSync extends SvrProcess
// Find Column in Database // Find Column in Database
Connection conn = null; Connection conn = null;
ResultSet rs = null;
try { try {
conn = DB.getConnectionRO(); conn = DB.getConnectionRO();
DatabaseMetaData md = conn.getMetaData(); DatabaseMetaData md = conn.getMetaData();
@ -98,7 +99,7 @@ public class ColumnSync extends SvrProcess
int noColumns = 0; int noColumns = 0;
String sql = null; String sql = null;
// //
ResultSet rs = md.getColumns(catalog, schema, tableName, null); rs = md.getColumns(catalog, schema, tableName, null);
while (rs.next()) while (rs.next())
{ {
noColumns++; noColumns++;
@ -111,7 +112,7 @@ public class ColumnSync extends SvrProcess
sql = column.getSQLModify(table, column.isMandatory() != notNull); sql = column.getSQLModify(table, column.isMandatory() != notNull);
break; break;
} }
rs.close(); DB.close(rs);
rs = null; rs = null;
// No Table // No Table
@ -149,6 +150,8 @@ public class ColumnSync extends SvrProcess
} }
return sql; return sql;
} finally { } finally {
DB.close(rs);
rs = null;
if (conn != null) { if (conn != null) {
try { try {
conn.close(); conn.close();

View File

@ -193,6 +193,7 @@ public class CostUpdate extends SvrProcess
sql += " AND M_Product_Category_ID=?"; sql += " AND M_Product_Category_ID=?";
int counter = 0; int counter = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
@ -202,28 +203,21 @@ public class CostUpdate extends SvrProcess
pstmt.setInt (4, as.getAD_Client_ID()); pstmt.setInt (4, as.getAD_Client_ID());
if (p_M_Product_Category_ID != 0) if (p_M_Product_Category_ID != 0)
pstmt.setInt (5, p_M_Product_Category_ID); pstmt.setInt (5, p_M_Product_Category_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
if (createNew (new MProduct (getCtx(), rs, null), as)) if (createNew (new MProduct (getCtx(), rs, null), as))
counter++; counter++;
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
log.info("#" + counter); log.info("#" + counter);
@ -256,13 +250,14 @@ public class CostUpdate extends SvrProcess
sql += " AND EXISTS (SELECT * FROM M_Product p " sql += " AND EXISTS (SELECT * FROM M_Product p "
+ "WHERE c.M_Product_ID=p.M_Product_ID AND p.M_Product_Category_ID=?)"; + "WHERE c.M_Product_ID=p.M_Product_ID AND p.M_Product_Category_ID=?)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, m_ce.getM_CostElement_ID()); pstmt.setInt (1, m_ce.getM_CostElement_ID());
if (p_M_Product_Category_ID != 0) if (p_M_Product_Category_ID != 0)
pstmt.setInt (2, p_M_Product_Category_ID); pstmt.setInt (2, p_M_Product_Category_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MCost cost = new MCost (getCtx(), rs, get_TrxName()); MCost cost = new MCost (getCtx(), rs, get_TrxName());
@ -277,22 +272,15 @@ public class CostUpdate extends SvrProcess
} }
} }
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
log.info("#" + counter); log.info("#" + counter);
@ -502,32 +490,26 @@ public class CostUpdate extends SvrProcess
+ "FROM M_ProductPrice " + "FROM M_ProductPrice "
+ "WHERE M_Product_ID=? AND M_PriceList_Version_ID=?"; + "WHERE M_Product_ID=? AND M_PriceList_Version_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, cost.getM_Product_ID()); pstmt.setInt (1, cost.getM_Product_ID());
pstmt.setInt (2, p_M_PriceList_Version_ID); pstmt.setInt (2, p_M_PriceList_Version_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
{ {
retValue = rs.getBigDecimal(1); retValue = rs.getBigDecimal(1);
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -78,11 +78,12 @@ public class DocumentTypeVerify extends SvrProcess
+ " AND rl.IsActive='Y' AND NOT EXISTS " + " AND rl.IsActive='Y' AND NOT EXISTS "
+ " (SELECT * FROM C_DocType dt WHERE dt.AD_Client_ID=? AND rl.Value=dt.DocBaseType)"; + " (SELECT * FROM C_DocType dt WHERE dt.AD_Client_ID=? AND rl.Value=dt.DocBaseType)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
String name = rs.getString(2); String name = rs.getString(2);
@ -104,22 +105,15 @@ public class DocumentTypeVerify extends SvrProcess
s_log.warning("Not created: " + name); s_log.warning("Not created: " + name);
} }
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
} // createDocumentTypes } // createDocumentTypes
@ -160,12 +154,13 @@ public class DocumentTypeVerify extends SvrProcess
+ " (SELECT * FROM C_PeriodControl pc " + " (SELECT * FROM C_PeriodControl pc "
+ "WHERE pc.C_Period_ID=p.C_Period_ID AND pc.DocBaseType=dt.DocBaseType)"; + "WHERE pc.C_Period_ID=p.C_Period_ID AND pc.DocBaseType=dt.DocBaseType)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int counter = 0; int counter = 0;
try try
{ {
pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int Client_ID = rs.getInt(1); int Client_ID = rs.getInt(1);
@ -184,22 +179,15 @@ public class DocumentTypeVerify extends SvrProcess
else else
s_log.warning("Not saved: " + pc); s_log.warning("Not saved: " + pc);
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
if (sp != null) if (sp != null)

View File

@ -203,6 +203,7 @@ public class DunningRunCreate extends SvrProcess
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement pstmt2 = null; PreparedStatement pstmt2 = null;
ResultSet rs = null; ResultSet rs = null;
ResultSet rs2 = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
@ -255,13 +256,14 @@ public class DunningRunCreate extends SvrProcess
// SubQuery // SubQuery
pstmt2.setInt (1, m_run.get_ID ()); pstmt2.setInt (1, m_run.get_ID ());
pstmt2.setInt (2, C_Invoice_ID); pstmt2.setInt (2, C_Invoice_ID);
ResultSet rs2 = pstmt2.executeQuery (); rs2 = pstmt2.executeQuery ();
if (rs2.next()) if (rs2.next())
{ {
TimesDunned = rs2.getInt(1); TimesDunned = rs2.getInt(1);
DaysAfterLast = rs2.getInt(2); DaysAfterLast = rs2.getInt(2);
} }
rs2.close(); DB.close(rs2);
rs2 = null;
// SubQuery // SubQuery
// Ensure that Daysbetween Dunning is enforced // Ensure that Daysbetween Dunning is enforced
@ -298,7 +300,8 @@ public class DunningRunCreate extends SvrProcess
finally finally
{ {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null; pstmt = null; pstmt2 = null; DB.close(rs2, pstmt2);
rs = null; pstmt = null; rs2 = null; pstmt2 = null;
} }
return count; return count;
} // addInvoices } // addInvoices

View File

@ -112,10 +112,11 @@ public class FactAcctReset extends SvrProcess
sql += " AND EXISTS (SELECT * FROM AD_Column c " sql += " AND EXISTS (SELECT * FROM AD_Column c "
+ "WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='Posted' AND c.IsActive='Y')"; + "WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='Posted' AND c.IsActive='Y')";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int AD_Table_ID = rs.getInt(1); int AD_Table_ID = rs.getInt(1);
@ -125,22 +126,15 @@ public class FactAcctReset extends SvrProcess
else else
reset (TableName); reset (TableName);
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// //

View File

@ -264,10 +264,12 @@ public class ImportAccount extends SvrProcess
.append("FROM I_ElementValue ") .append("FROM I_ElementValue ")
.append("WHERE I_IsImported='N'").append(clientCheck) .append("WHERE I_IsImported='N'").append(clientCheck)
.append(" ORDER BY I_ElementValue_ID"); .append(" ORDER BY I_ElementValue_ID");
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
X_I_ElementValue impEV = new X_I_ElementValue(getCtx(), rs, get_TrxName()); X_I_ElementValue impEV = new X_I_ElementValue(getCtx(), rs, get_TrxName());
@ -316,13 +318,17 @@ public class ImportAccount extends SvrProcess
} }
} }
} // for all I_Product } // for all I_Product
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
throw new Exception ("create", e); throw new Exception ("create", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_ElementValue ") sql = new StringBuilder ("UPDATE I_ElementValue ")
@ -362,8 +368,8 @@ public class ImportAccount extends SvrProcess
int noParentUpdate = 0; int noParentUpdate = 0;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
String updateSQL = "UPDATE AD_TreeNode SET Parent_ID=?, SeqNo=? " String updateSQL = "UPDATE AD_TreeNode SET Parent_ID=?, SeqNo=? "
+ "WHERE AD_Tree_ID=? AND Node_ID=?"; + "WHERE AD_Tree_ID=? AND Node_ID=?";
@ -391,13 +397,17 @@ public class ImportAccount extends SvrProcess
if (no == 0) if (no == 0)
log.info("Parent not found for " + rs.getString(5)); log.info("Parent not found for " + rs.getString(5));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "(ParentUpdateLoop) " + sql.toString(), e); log.log(Level.SEVERE, "(ParentUpdateLoop) " + sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
addLog (0, null, new BigDecimal (noParentUpdate), "@ParentElementValue_ID@: @Updated@"); addLog (0, null, new BigDecimal (noParentUpdate), "@ParentElementValue_ID@: @Updated@");
commitEx(); commitEx();
@ -444,20 +454,26 @@ public class ImportAccount extends SvrProcess
// **** Update Defaults // **** Update Defaults
StringBuilder sql = new StringBuilder ("SELECT C_AcctSchema_ID FROM C_AcctSchema_Element ") StringBuilder sql = new StringBuilder ("SELECT C_AcctSchema_ID FROM C_AcctSchema_Element ")
.append("WHERE C_Element_ID=?").append(clientCheck); .append("WHERE C_Element_ID=?").append(clientCheck);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, m_C_Element_ID); pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
updateDefaultAccounts (rs.getInt(1)); updateDefaultAccounts (rs.getInt(1));
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Default Account DEFAULT_ACCT // Default Account DEFAULT_ACCT
sql = new StringBuilder ("UPDATE C_AcctSchema_Element e ") sql = new StringBuilder ("UPDATE C_AcctSchema_Element e ")
@ -498,11 +514,13 @@ public class ImportAccount extends SvrProcess
.append(" INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) ") .append(" INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) ")
.append("WHERE i.I_IsImported='Y' AND Processing='Y'") .append("WHERE i.I_IsImported='Y' AND Processing='Y'")
.append(" AND i.C_ElementValue_ID IS NOT NULL AND C_Element_ID=?"); .append(" AND i.C_ElementValue_ID IS NOT NULL AND C_Element_ID=?");
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, m_C_Element_ID); pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int C_ElementValue_ID = rs.getInt(1); int C_ElementValue_ID = rs.getInt(1);
@ -521,13 +539,17 @@ public class ImportAccount extends SvrProcess
log.log(Level.SEVERE, "Updated=" + no); log.log(Level.SEVERE, "Updated=" + no);
} }
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
addLog (0, null, new BigDecimal (counts[UPDATE_ERROR]), as.toString() + ": @Errors@"); addLog (0, null, new BigDecimal (counts[UPDATE_ERROR]), as.toString() + ": @Errors@");
addLog (0, null, new BigDecimal (counts[UPDATE_YES]), as.toString() + ": @Updated@"); addLog (0, null, new BigDecimal (counts[UPDATE_YES]), as.toString() + ": @Updated@");
addLog (0, null, new BigDecimal (counts[UPDATE_SAME]), as.toString() + ": OK"); addLog (0, null, new BigDecimal (counts[UPDATE_SAME]), as.toString() + ": OK");
@ -562,10 +584,12 @@ public class ImportAccount extends SvrProcess
.append(TableName).append(" x INNER JOIN C_ValidCombination vc ON (x.") .append(TableName).append(" x INNER JOIN C_ValidCombination vc ON (x.")
.append(ColumnName).append("=vc.C_ValidCombination_ID) ") .append(ColumnName).append("=vc.C_ValidCombination_ID) ")
.append("WHERE x.C_AcctSchema_ID=").append(C_AcctSchema_ID); .append("WHERE x.C_AcctSchema_ID=").append(C_AcctSchema_ID);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
int C_ValidCombination_ID = rs.getInt(1); int C_ValidCombination_ID = rs.getInt(1);
@ -635,13 +659,17 @@ public class ImportAccount extends SvrProcess
} // for all default accounts } // for all default accounts
else else
log.log(Level.SEVERE, "Account not found " + sql); log.log(Level.SEVERE, "Account not found " + sql);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue; return retValue;
} // updateDefaultAccount } // updateDefaultAccount

View File

@ -329,11 +329,12 @@ public class ImportBankStatement extends SvrProcess
PreparedStatement pupdt = DB.prepareStatement(updateSql.toString(), get_TrxName()); PreparedStatement pupdt = DB.prepareStatement(updateSql.toString(), get_TrxName());
PreparedStatement pstmtDuplicates = null; PreparedStatement pstmtDuplicates = null;
ResultSet rs = null;
no = 0; no = 0;
try try
{ {
pstmtDuplicates = DB.prepareStatement(sql.toString(), get_TrxName()); pstmtDuplicates = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmtDuplicates.executeQuery(); rs = pstmtDuplicates.executeQuery();
while (rs.next()) while (rs.next())
{ {
StringBuilder info = new StringBuilder("Line_ID=").append(rs.getInt(2)) // l.C_BankStatementLine_ID StringBuilder info = new StringBuilder("Line_ID=").append(rs.getInt(2)) // l.C_BankStatementLine_ID
@ -343,18 +344,18 @@ public class ImportBankStatement extends SvrProcess
pupdt.executeUpdate(); pupdt.executeUpdate();
no++; no++;
} }
rs.close();
pstmtDuplicates.close();
pupdt.close();
rs = null;
pstmtDuplicates = null;
pupdt = null;
} }
catch(Exception e) catch(Exception e)
{ {
log.log(Level.SEVERE, "DetectDuplicates " + e.getMessage()); log.log(Level.SEVERE, "DetectDuplicates " + e.getMessage());
} }
finally
{
DB.close(rs, pstmtDuplicates);
rs = null;pstmtDuplicates = null;
DB.close(pupdt);
pupdt = null;
}
if (no != 0) if (no != 0)
log.info("Duplicates=" + no); log.info("Duplicates=" + no);
@ -374,7 +375,7 @@ public class ImportBankStatement extends SvrProcess
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -508,18 +509,17 @@ public class ImportBankStatement extends SvrProcess
line = null; line = null;
} }
// Close database connection
rs.close();
pstmt.close();
rs = null;
pstmt = null;
} }
catch(Exception e) catch(Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_BankStatement ") sql = new StringBuilder ("UPDATE I_BankStatement ")

View File

@ -236,10 +236,11 @@ public class ImportConversionRate extends SvrProcess
.append("WHERE I_IsImported='N'").append (clientCheck) .append("WHERE I_IsImported='N'").append (clientCheck)
.append(" ORDER BY C_Currency_ID, C_Currency_ID_To, ValidFrom"); .append(" ORDER BY C_Currency_ID, C_Currency_ID_To, ValidFrom");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
X_I_Conversion_Rate imp = new X_I_Conversion_Rate (getCtx(), rs, get_TrxName()); X_I_Conversion_Rate imp = new X_I_Conversion_Rate (getCtx(), rs, get_TrxName());
@ -270,22 +271,15 @@ public class ImportConversionRate extends SvrProcess
} }
} }
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }

View File

@ -588,10 +588,11 @@ public class ImportGLJournal extends SvrProcess
.append("FROM I_GLJournal ") .append("FROM I_GLJournal ")
.append("WHERE I_IsImported='N'").append (clientCheck); .append("WHERE I_IsImported='N'").append (clientCheck);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
{ {
BigDecimal source = rs.getBigDecimal(1); BigDecimal source = rs.getBigDecimal(1);
@ -608,23 +609,17 @@ public class ImportGLJournal extends SvrProcess
if (acct != null) if (acct != null)
addLog (0, null, acct, "@AmtAcctDr@ - @AmtAcctCr@"); addLog (0, null, acct, "@AmtAcctDr@ - @AmtAcctCr@");
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, sql.toString(), ex); log.log(Level.SEVERE, sql.toString(), ex);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
// globalqss (moved the commit here to save the error messages) // globalqss (moved the commit here to save the error messages)
commitEx(); commitEx();
@ -669,7 +664,7 @@ public class ImportGLJournal extends SvrProcess
try try
{ {
pstmt = DB.prepareStatement (sql.toString (), get_TrxName()); pstmt = DB.prepareStatement (sql.toString (), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
// //
while (rs.next()) while (rs.next())
{ {
@ -831,23 +826,18 @@ public class ImportGLJournal extends SvrProcess
noInsertLine++; noInsertLine++;
} }
} // while records } // while records
rs.close();
pstmt.close();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
// clean up // clean up
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_GLJournal ") sql = new StringBuilder ("UPDATE I_GLJournal ")

View File

@ -139,6 +139,7 @@ public class ImportInOutConfirm extends SvrProcess
/*********************************************************************/ /*********************************************************************/
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
sql = new StringBuilder ("SELECT * FROM I_InOutLineConfirm ") sql = new StringBuilder ("SELECT * FROM I_InOutLineConfirm ")
.append("WHERE I_IsImported='N'").append (clientCheck) .append("WHERE I_IsImported='N'").append (clientCheck)
.append(" ORDER BY I_InOutLineConfirm_ID"); .append(" ORDER BY I_InOutLineConfirm_ID");
@ -146,7 +147,7 @@ public class ImportInOutConfirm extends SvrProcess
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
X_I_InOutLineConfirm importLine = new X_I_InOutLineConfirm (getCtx(), rs, get_TrxName()); X_I_InOutLineConfirm importLine = new X_I_InOutLineConfirm (getCtx(), rs, get_TrxName());
@ -176,22 +177,15 @@ public class ImportInOutConfirm extends SvrProcess
} }
} }
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
StringBuilder msgreturn = new StringBuilder("@Updated@ #").append(no); StringBuilder msgreturn = new StringBuilder("@Updated@ #").append(no);

View File

@ -483,10 +483,12 @@ public class ImportInvoice extends SvrProcess
// Go through Invoice Records w/o C_BPartner_ID // Go through Invoice Records w/o C_BPartner_ID
sql = new StringBuilder ("SELECT * FROM I_Invoice ") sql = new StringBuilder ("SELECT * FROM I_Invoice ")
.append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck); .append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
X_I_Invoice imp = new X_I_Invoice (getCtx(), rs, get_TrxName()); X_I_Invoice imp = new X_I_Invoice (getCtx(), rs, get_TrxName());
@ -593,14 +595,18 @@ public class ImportInvoice extends SvrProcess
} }
imp.save (); imp.save ();
} // for all new BPartners } // for all new BPartners
rs.close ();
pstmt.close ();
// //
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "CreateBP", e); log.log(Level.SEVERE, "CreateBP", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
sql = new StringBuilder ("UPDATE I_Invoice ") sql = new StringBuilder ("UPDATE I_Invoice ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ")
.append("WHERE C_BPartner_ID IS NULL") .append("WHERE C_BPartner_ID IS NULL")
@ -622,8 +628,8 @@ public class ImportInvoice extends SvrProcess
.append(" ORDER BY C_BPartner_ID, C_BPartner_Location_ID, I_Invoice_ID"); .append(" ORDER BY C_BPartner_ID, C_BPartner_Location_ID, I_Invoice_ID");
try try
{ {
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
// Group Change // Group Change
int oldC_BPartner_ID = 0; int oldC_BPartner_ID = 0;
int oldC_BPartner_Location_ID = 0; int oldC_BPartner_Location_ID = 0;
@ -751,13 +757,17 @@ public class ImportInvoice extends SvrProcess
} }
invoice.saveEx(); invoice.saveEx();
} }
rs.close();
pstmt.close();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "CreateInvoice", e); log.log(Level.SEVERE, "CreateInvoice", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Invoice ") sql = new StringBuilder ("UPDATE I_Invoice ")

View File

@ -499,10 +499,12 @@ public class ImportOrder extends SvrProcess
// Go through Order Records w/o C_BPartner_ID // Go through Order Records w/o C_BPartner_ID
sql = new StringBuilder ("SELECT * FROM I_Order ") sql = new StringBuilder ("SELECT * FROM I_Order ")
.append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck); .append("WHERE I_IsImported='N' AND C_BPartner_ID IS NULL").append (clientCheck);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
X_I_Order imp = new X_I_Order (getCtx (), rs, get_TrxName()); X_I_Order imp = new X_I_Order (getCtx (), rs, get_TrxName());
@ -610,14 +612,18 @@ public class ImportOrder extends SvrProcess
} }
imp.save (); imp.save ();
} // for all new BPartners } // for all new BPartners
rs.close ();
pstmt.close ();
// //
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "BP - " + sql.toString(), e); log.log(Level.SEVERE, "BP - " + sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
sql = new StringBuilder ("UPDATE I_Order ") sql = new StringBuilder ("UPDATE I_Order ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No BPartner, ' ")
.append("WHERE C_BPartner_ID IS NULL") .append("WHERE C_BPartner_ID IS NULL")
@ -639,8 +645,8 @@ public class ImportOrder extends SvrProcess
.append(" ORDER BY C_BPartner_ID, BillTo_ID, C_BPartner_Location_ID, I_Order_ID"); .append(" ORDER BY C_BPartner_ID, BillTo_ID, C_BPartner_Location_ID, I_Order_ID");
try try
{ {
PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
// //
int oldC_BPartner_ID = 0; int oldC_BPartner_ID = 0;
int oldBillTo_ID = 0; int oldBillTo_ID = 0;
@ -779,13 +785,17 @@ public class ImportOrder extends SvrProcess
} }
order.saveEx(); order.saveEx();
} }
rs.close();
pstmt.close();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "Order - " + sql.toString(), e); log.log(Level.SEVERE, "Order - " + sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Order ") sql = new StringBuilder ("UPDATE I_Order ")

View File

@ -413,11 +413,12 @@ public class ImportPayment extends SvrProcess
MBankAccount account = null; MBankAccount account = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int noInsert = 0; int noInsert = 0;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -512,18 +513,17 @@ public class ImportPayment extends SvrProcess
} }
} }
// Close database connection
rs.close();
pstmt.close();
rs = null;
pstmt = null;
} }
catch(Exception e) catch(Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Payment ") sql = new StringBuilder ("UPDATE I_Payment ")

View File

@ -385,20 +385,26 @@ public class ImportProduct extends SvrProcess implements ImportProcess
// Get Default Tax Category // Get Default Tax Category
int C_TaxCategory_ID = 0; int C_TaxCategory_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
StringBuilder dbpst = new StringBuilder("SELECT C_TaxCategory_ID FROM C_TaxCategory WHERE IsDefault='Y'").append(clientCheck); StringBuilder dbpst = new StringBuilder("SELECT C_TaxCategory_ID FROM C_TaxCategory WHERE IsDefault='Y'").append(clientCheck);
PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName()); pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
C_TaxCategory_ID = rs.getInt(1); C_TaxCategory_ID = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
throw new Exception ("TaxCategory", e); throw new Exception ("TaxCategory", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("C_TaxCategory_ID=" + C_TaxCategory_ID); log.fine("C_TaxCategory_ID=" + C_TaxCategory_ID);
ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE); ModelValidationEngine.get().fireImportValidate(this, null, null, ImportValidator.TIMING_AFTER_VALIDATE);
@ -415,6 +421,8 @@ public class ImportProduct extends SvrProcess implements ImportProcess
log.fine("start inserting/updating ..."); log.fine("start inserting/updating ...");
sql = new StringBuilder ("SELECT * FROM I_Product WHERE I_IsImported='N'") sql = new StringBuilder ("SELECT * FROM I_Product WHERE I_IsImported='N'")
.append(clientCheck); .append(clientCheck);
PreparedStatement pstmt_setImported = null;
PreparedStatement pstmt_insertProductPO = null;
try try
{ {
/* Insert Product from Import /* Insert Product from Import
@ -468,7 +476,7 @@ public class ImportProduct extends SvrProcess implements ImportProcess
(sqlt, get_TrxName()); (sqlt, get_TrxName());
*/ */
// Insert Product from Import // Insert Product from Import
PreparedStatement pstmt_insertProductPO = DB.prepareStatement pstmt_insertProductPO = DB.prepareStatement
("INSERT INTO M_Product_PO (M_Product_ID,C_BPartner_ID, " ("INSERT INTO M_Product_PO (M_Product_ID,C_BPartner_ID, "
+ "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy," + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
+ "IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC," + "IsCurrentVendor,C_UOM_ID,C_Currency_ID,UPC,"
@ -487,13 +495,13 @@ public class ImportProduct extends SvrProcess implements ImportProcess
+ "WHERE I_Product_ID=?", get_TrxName()); + "WHERE I_Product_ID=?", get_TrxName());
// Set Imported = Y // Set Imported = Y
PreparedStatement pstmt_setImported = DB.prepareStatement pstmt_setImported = DB.prepareStatement
("UPDATE I_Product SET I_IsImported='Y', M_Product_ID=?, " ("UPDATE I_Product SET I_IsImported='Y', M_Product_ID=?, "
+ "Updated=SysDate, Processed='Y' WHERE I_Product_ID=?", get_TrxName()); + "Updated=SysDate, Processed='Y' WHERE I_Product_ID=?", get_TrxName());
// //
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
X_I_Product imp = new X_I_Product(getCtx(), rs, get_TrxName()); X_I_Product imp = new X_I_Product(getCtx(), rs, get_TrxName());
@ -558,7 +566,11 @@ public class ImportProduct extends SvrProcess implements ImportProcess
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
} }
pstmt_updateProduct.close(); finally
{
DB.close(pstmt_updateProduct);
pstmt_updateProduct = null;
}
} }
// Do we have PO Info // Do we have PO Info
@ -604,7 +616,11 @@ public class ImportProduct extends SvrProcess implements ImportProcess
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
} }
pstmt_updateProductPO.close(); finally
{
DB.close(pstmt_updateProductPO);
pstmt_updateProductPO = null;
}
} }
if (no == 0) // Insert PO if (no == 0) // Insert PO
{ {
@ -657,20 +673,19 @@ public class ImportProduct extends SvrProcess implements ImportProcess
// //
commitEx(); commitEx();
} // for all I_Product } // for all I_Product
rs.close();
pstmt.close();
//
// pstmt_insertProduct.close();
// pstmt_updateProduct.close();
pstmt_insertProductPO.close();
// pstmt_updateProductPO.close();
pstmt_setImported.close();
//
} }
catch (SQLException e) catch (SQLException e)
{ {
} }
finally
{
DB.close(rs, pstmt);
rs = null;pstmt = null;
DB.close(pstmt_insertProductPO);
pstmt_insertProductPO = null;
DB.close(pstmt_setImported);
pstmt_setImported = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Product ") sql = new StringBuilder ("UPDATE I_Product ")

View File

@ -265,6 +265,9 @@ public class ImportReportLine extends SvrProcess
.append("FROM I_ReportLine ") .append("FROM I_ReportLine ")
.append("WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL") .append("WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL")
.append(" AND I_IsImported='N'").append(clientCheck); .append(" AND I_IsImported='N'").append(clientCheck);
PreparedStatement pstmt_insertLine = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
// Insert ReportLine // Insert ReportLine
@ -283,10 +286,10 @@ public class ImportReportLine extends SvrProcess
.append("WHERE PA_ReportLineSet_ID=? AND Name=? ") // #2..3 .append("WHERE PA_ReportLineSet_ID=? AND Name=? ") // #2..3
//jz + clientCheck, get_TrxName()); //jz + clientCheck, get_TrxName());
.append(clientCheck).append(")"); .append(clientCheck).append(")");
PreparedStatement pstmt_insertLine = DB.prepareStatement(dbpst.toString(), get_TrxName()); pstmt_insertLine = DB.prepareStatement(dbpst.toString(), get_TrxName());
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int PA_ReportLineSet_ID = rs.getInt(1); int PA_ReportLineSet_ID = rs.getInt(1);
@ -311,15 +314,18 @@ public class ImportReportLine extends SvrProcess
continue; continue;
} }
} }
rs.close();
pstmt.close();
//
pstmt_insertLine.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "Create ReportLine", e); log.log(Level.SEVERE, "Create ReportLine", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;pstmt = null;
DB.close(pstmt_insertLine);
pstmt_insertLine = null;
}
// Set PA_ReportLine_ID (for newly created) // Set PA_ReportLine_ID (for newly created)
sql = new StringBuilder ("UPDATE I_ReportLine i ") sql = new StringBuilder ("UPDATE I_ReportLine i ")
@ -356,6 +362,9 @@ public class ImportReportLine extends SvrProcess
.append("WHERE PA_ReportLine_ID IS NOT NULL") .append("WHERE PA_ReportLine_ID IS NOT NULL")
.append(" AND I_IsImported='N'").append(clientCheck); .append(" AND I_IsImported='N'").append(clientCheck);
PreparedStatement pstmt_insertSource = null;
PreparedStatement pstmt_deleteSource = null;
PreparedStatement pstmt_setImported = null;
try try
{ {
// Insert ReportSource // Insert ReportSource
@ -370,7 +379,7 @@ public class ImportReportLine extends SvrProcess
.append("WHERE I_ReportLine_ID=?") .append("WHERE I_ReportLine_ID=?")
.append(" AND I_IsImported='N'") .append(" AND I_IsImported='N'")
.append(clientCheck); .append(clientCheck);
PreparedStatement pstmt_insertSource = DB.prepareStatement(dbpst.toString(), get_TrxName()); pstmt_insertSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
// Update ReportSource // Update ReportSource
//jz //jz
@ -391,17 +400,17 @@ public class ImportReportLine extends SvrProcess
.append("WHERE C_ElementValue_ID IS NULL") .append("WHERE C_ElementValue_ID IS NULL")
.append(" AND PA_ReportSource_ID=?") .append(" AND PA_ReportSource_ID=?")
.append(clientCheck); .append(clientCheck);
PreparedStatement pstmt_deleteSource = DB.prepareStatement(dbpst.toString(), get_TrxName()); pstmt_deleteSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
//End afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports //End afalcone 22/02/2007 - F.R. [ 1642250 ] Import ReportLine / Very Slow Reports
// Set Imported = Y // Set Imported = Y
PreparedStatement pstmt_setImported = DB.prepareStatement pstmt_setImported = DB.prepareStatement
("UPDATE I_ReportLine SET I_IsImported='Y'," ("UPDATE I_ReportLine SET I_IsImported='Y',"
+ " PA_ReportSource_ID=?, " + " PA_ReportSource_ID=?, "
+ " Updated=SysDate, Processed='Y' WHERE I_ReportLine_ID=?", get_TrxName()); + " Updated=SysDate, Processed='Y' WHERE I_ReportLine_ID=?", get_TrxName());
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int I_ReportLine_ID = rs.getInt(1); int I_ReportLine_ID = rs.getInt(1);
@ -461,7 +470,11 @@ public class ImportReportLine extends SvrProcess
DB.executeUpdate(sql.toString(), get_TrxName()); DB.executeUpdate(sql.toString(), get_TrxName());
continue; continue;
} }
pstmt_updateSource.close(); finally
{
DB.close(pstmt_updateSource);
pstmt_updateSource = null;
}
} // update source } // update source
// Set Imported to Y // Set Imported to Y
@ -481,17 +494,19 @@ public class ImportReportLine extends SvrProcess
commitEx(); commitEx();
} }
rs.close();
pstmt.close();
//
pstmt_insertSource.close();
//jz pstmt_updateSource.close();
pstmt_setImported.close();
//
} }
catch (SQLException e) catch (SQLException e)
{ {
} }
finally
{
DB.close(rs, pstmt);
rs = null;pstmt = null;
DB.close(pstmt_insertSource);
pstmt_insertSource = null;
DB.close(pstmt_setImported);
pstmt_setImported = null;
}
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_ReportLine ") sql = new StringBuilder ("UPDATE I_ReportLine ")

View File

@ -209,9 +209,10 @@ public class InOutGenerate extends SvrProcess
private String generate (PreparedStatement pstmt) private String generate (PreparedStatement pstmt)
{ {
ResultSet rs = null;
try try
{ {
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) // Order while (rs.next ()) // Order
{ {
MOrder order = new MOrder (getCtx(), rs, get_TrxName()); MOrder order = new MOrder (getCtx(), rs, get_TrxName());
@ -391,22 +392,15 @@ public class InOutGenerate extends SvrProcess
} }
m_line += 1000; m_line += 1000;
} // while order } // while order
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, m_sql.toString(), e); log.log(Level.SEVERE, m_sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
completeShipment(); completeShipment();

View File

@ -200,6 +200,7 @@ public class InventoryCountCreate extends SvrProcess
// //
int count = 0; int count = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
@ -213,7 +214,7 @@ public class InventoryCountCreate extends SvrProcess
pstmt.setString(index++, p_ProductValue.toUpperCase()); pstmt.setString(index++, p_ProductValue.toUpperCase());
if (!p_DeleteOld) if (!p_DeleteOld)
pstmt.setInt(index++, p_M_Inventory_ID); pstmt.setInt(index++, p_M_Inventory_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
int M_Product_ID = rs.getInt(1); int M_Product_ID = rs.getInt(1);
@ -235,22 +236,15 @@ public class InventoryCountCreate extends SvrProcess
M_AttributeSetInstance_ID, QtyOnHand, M_AttributeSet_ID); M_AttributeSetInstance_ID, QtyOnHand, M_AttributeSet_ID);
} }
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
@ -354,8 +348,12 @@ public class InventoryCountCreate extends SvrProcess
StringBuilder retString = new StringBuilder(); StringBuilder retString = new StringBuilder();
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category"; String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100); final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
Statement stmt = DB.createStatement(); Statement stmt = null;
ResultSet rs = stmt.executeQuery(sql); ResultSet rs = null;
try
{
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) { while (rs.next()) {
if(rs.getInt(1)==productCategoryId) { if(rs.getInt(1)==productCategoryId) {
subTreeRootParentId = rs.getInt(2); subTreeRootParentId = rs.getInt(2);
@ -363,8 +361,15 @@ public class InventoryCountCreate extends SvrProcess
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2))); categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
} }
retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId)); retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId));
rs.close(); } catch (SQLException e)
stmt.close(); {
throw e;
}
finally
{
DB.close(rs, stmt);
rs = null;stmt = null;
}
return retString.toString(); return retString.toString();
} }

View File

@ -136,11 +136,12 @@ public class InventoryCountUpdate extends SvrProcess
// //
String sql = "SELECT * FROM M_InventoryLine WHERE M_Inventory_ID=? AND M_AttributeSetInstance_ID=0"; String sql = "SELECT * FROM M_InventoryLine WHERE M_Inventory_ID=? AND M_AttributeSetInstance_ID=0";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, p_M_Inventory_ID); pstmt.setInt (1, p_M_Inventory_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MInventoryLine il = new MInventoryLine (getCtx(), rs, get_TrxName()); MInventoryLine il = new MInventoryLine (getCtx(), rs, get_TrxName());
@ -168,22 +169,15 @@ public class InventoryCountUpdate extends SvrProcess
if (il.save()) if (il.save())
no++; no++;
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql, e); log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// //

View File

@ -191,9 +191,10 @@ public class InvoiceGenerate extends SvrProcess
*/ */
private String generate (PreparedStatement pstmt) private String generate (PreparedStatement pstmt)
{ {
ResultSet rs = null;
try try
{ {
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MOrder order = new MOrder (getCtx(), rs, get_TrxName()); MOrder order = new MOrder (getCtx(), rs, get_TrxName());
@ -320,22 +321,15 @@ public class InvoiceGenerate extends SvrProcess
} }
} // complete Order } // complete Order
} // for all orders } // for all orders
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
completeInvoice(); completeInvoice();

View File

@ -170,32 +170,26 @@ public class InvoiceWriteOff extends SvrProcess
// //
int counter = 0; int counter = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
if (writeOff(rs.getInt(1), rs.getString(2), rs.getTimestamp(3), if (writeOff(rs.getInt(1), rs.getString(2), rs.getTimestamp(3),
rs.getInt(4), rs.getBigDecimal(6))) rs.getInt(4), rs.getBigDecimal(6)))
counter++; counter++;
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// final // final

View File

@ -110,20 +110,26 @@ public class M_Product_BOM_Check extends SvrProcess
// Get count remaining on t_selection // Get count remaining on t_selection
int countno = 0; int countno = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
StringBuilder dbpst = new StringBuilder("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID); StringBuilder dbpst = new StringBuilder("SELECT COUNT(*) FROM T_Selection WHERE AD_PInstance_ID=").append(m_AD_PInstance_ID);
PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName()); pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
countno = rs.getInt(1); countno = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
throw new Exception ("count t_selection", e); throw new Exception ("count t_selection", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("Count T_Selection =" + countno); log.fine("Count T_Selection =" + countno);
if (countno == 0) if (countno == 0)

View File

@ -128,12 +128,13 @@ public class OrderBatchProcess extends SvrProcess
int counter = 0; int counter = 0;
int errCounter = 0; int errCounter = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, p_C_DocTypeTarget_ID); pstmt.setInt(1, p_C_DocTypeTarget_ID);
pstmt.setString(2, p_DocStatus); pstmt.setString(2, p_DocStatus);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
if (process(new MOrder(getCtx(),rs, get_TrxName()))) if (process(new MOrder(getCtx(),rs, get_TrxName())))
@ -141,22 +142,15 @@ public class OrderBatchProcess extends SvrProcess
else else
errCounter++; errCounter++;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
StringBuilder msgreturn = new StringBuilder("@Updated@=").append(counter).append(", @Errors@=").append(errCounter); StringBuilder msgreturn = new StringBuilder("@Updated@=").append(counter).append(", @Errors@=").append(errCounter);

View File

@ -184,6 +184,7 @@ public class PaySelectionCreateFrom extends SvrProcess
int lines = 0; int lines = 0;
int C_CurrencyTo_ID = psel.getC_Currency_ID(); int C_CurrencyTo_ID = psel.getC_Currency_ID();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
@ -207,7 +208,7 @@ public class PaySelectionCreateFrom extends SvrProcess
else if (p_C_BP_Group_ID != 0) else if (p_C_BP_Group_ID != 0)
pstmt.setInt (index++, p_C_BP_Group_ID); pstmt.setInt (index++, p_C_BP_Group_ID);
// //
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
int C_Invoice_ID = rs.getInt(1); int C_Invoice_ID = rs.getInt(1);
@ -228,22 +229,15 @@ public class PaySelectionCreateFrom extends SvrProcess
throw new IllegalStateException ("Cannot save MPaySelectionLine"); throw new IllegalStateException ("Cannot save MPaySelectionLine");
} }
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
StringBuilder msgreturn = new StringBuilder("@C_PaySelectionLine_ID@ - #").append(lines); StringBuilder msgreturn = new StringBuilder("@C_PaySelectionLine_ID@ - #").append(lines);

View File

@ -737,29 +737,23 @@ public class ReplenishReport extends SvrProcess
sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID"); sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID");
ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>(); ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
pstmt.setInt (1, getAD_PInstance_ID()); pstmt.setInt (1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new X_T_Replenish (getCtx(), rs, get_TrxName())); list.add (new X_T_Replenish (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
X_T_Replenish[] retValue = new X_T_Replenish[list.size ()]; X_T_Replenish[] retValue = new X_T_Replenish[list.size ()];
@ -780,29 +774,23 @@ public class ReplenishReport extends SvrProcess
sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID"); sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID");
ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>(); ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
pstmt.setInt (1, getAD_PInstance_ID()); pstmt.setInt (1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new X_T_Replenish (getCtx(), rs, get_TrxName())); list.add (new X_T_Replenish (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
X_T_Replenish[] retValue = new X_T_Replenish[list.size ()]; X_T_Replenish[] retValue = new X_T_Replenish[list.size ()];

View File

@ -838,29 +838,23 @@ public class ReplenishReportProduction extends SvrProcess
sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID"); sql.append(" ORDER BY M_Warehouse_ID, M_WarehouseSource_ID, C_BPartner_ID");
ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>(); ArrayList<X_T_Replenish> list = new ArrayList<X_T_Replenish>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
pstmt.setInt (1, getAD_PInstance_ID()); pstmt.setInt (1, getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new X_T_Replenish (getCtx(), rs, get_TrxName())); list.add (new X_T_Replenish (getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
X_T_Replenish[] retValue = new X_T_Replenish[list.size ()]; X_T_Replenish[] retValue = new X_T_Replenish[list.size ()];

View File

@ -227,14 +227,17 @@ public class ReplicationLocal extends SvrProcess
{ {
while (rowset.next()) while (rowset.next())
mergeDataTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4)); mergeDataTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4));
rowset.close();
rowset = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, "mergeData", ex); log.log(Level.SEVERE, "mergeData", ex);
m_replicated = false; m_replicated = false;
} }
finally
{
DB.close(rowset);
rowset = null;
}
} // mergeData } // mergeData
/** /**
@ -318,9 +321,9 @@ public class ReplicationLocal extends SvrProcess
rLog.setIsReplicated(replicated); rLog.setIsReplicated(replicated);
if (result != null) if (result != null)
rLog.setP_Msg("< " + result.toString()); rLog.setP_Msg("< " + result.toString());
sourceRS.close(); DB.close(sourceRS);
sourceRS = null; sourceRS = null;
targetRS.close(); DB.close(targetRS);
targetRS = null; targetRS = null;
} }
rLog.saveEx(); rLog.saveEx();
@ -336,6 +339,7 @@ public class ReplicationLocal extends SvrProcess
{ {
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
// Get Keys // Get Keys
@ -344,14 +348,14 @@ public class ReplicationLocal extends SvrProcess
+ " AND IsKey='Y'"; + " AND IsKey='Y'";
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, AD_Table_ID); pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(rs.getString(1)); list.add(rs.getString(1));
rs.close();
// no keys - search for parents // no keys - search for parents
if (list.size() == 0) if (list.size() == 0)
{ {
DB.close(rs);
rs = null;
sql = "SELECT ColumnName FROM AD_Column " sql = "SELECT ColumnName FROM AD_Column "
+ "WHERE AD_Table_ID=?" + "WHERE AD_Table_ID=?"
+ " AND IsParent='Y'"; + " AND IsParent='Y'";
@ -360,22 +364,17 @@ public class ReplicationLocal extends SvrProcess
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(rs.getString(1)); list.add(rs.getString(1));
rs.close();
} }
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "getKeyColumns", e); log.log(Level.SEVERE, "getKeyColumns", e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
// Convert to Array // Convert to Array
@ -406,13 +405,17 @@ public class ReplicationLocal extends SvrProcess
{ {
while (rowset.next()) while (rowset.next())
sendUpdatesTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4)); sendUpdatesTable (rowset.getInt(1), rowset.getString(3), rowset.getInt(4));
rowset.close();
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, "sendUpdates", ex); log.log(Level.SEVERE, "sendUpdates", ex);
m_replicated = false; m_replicated = false;
} }
finally
{
DB.close(rowset);
rowset = null;
}
} // sendUpdates } // sendUpdates
/** /**
@ -534,6 +537,7 @@ public class ReplicationLocal extends SvrProcess
Connection conn = DB.getConnectionRO(); Connection conn = DB.getConnectionRO();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
RowSet rowSet = null; RowSet rowSet = null;
ResultSet rs = null;
// //
try try
{ {
@ -557,7 +561,7 @@ public class ReplicationLocal extends SvrProcess
} }
} }
// //
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
rowSet = CCachedRowSet.getRowSet(rs); rowSet = CCachedRowSet.getRowSet(rs);
} }
catch (Exception ex) catch (Exception ex)
@ -568,8 +572,8 @@ public class ReplicationLocal extends SvrProcess
// Close Cursor // Close Cursor
finally finally
{ {
DB.close(pstmt); DB.close(rs,pstmt);
pstmt = null; rs = null;pstmt = null;
} }
return rowSet; return rowSet;

View File

@ -352,16 +352,25 @@ public class RequestEMailProcessor extends SvrProcess
+ "and documentno = ? " + "and documentno = ? "
+ "and startdate = ?"; + "and startdate = ?";
PreparedStatement pstmtdup = null; PreparedStatement pstmtdup = null;
ResultSet rsdup = null;
try
{
pstmtdup = DB.prepareStatement (sqldup, null); pstmtdup = DB.prepareStatement (sqldup, null);
pstmtdup.setInt(1, getAD_Client_ID()); pstmtdup.setInt(1, getAD_Client_ID());
pstmtdup.setString(2, hdrs[0].substring(0,30)); pstmtdup.setString(2, hdrs[0].substring(0,30));
pstmtdup.setTimestamp(3, new Timestamp(msg.getSentDate().getTime())); pstmtdup.setTimestamp(3, new Timestamp(msg.getSentDate().getTime()));
ResultSet rsdup = pstmtdup.executeQuery (); rsdup = pstmtdup.executeQuery ();
if (rsdup.next ()) if (rsdup.next ())
retValuedup = rsdup.getInt(1); retValuedup = rsdup.getInt(1);
rsdup.close (); } catch (SQLException e)
pstmtdup.close (); {
pstmtdup = null; throw e;
}
finally
{
DB.close (rsdup,pstmtdup);
rsdup = null;pstmtdup = null;
}
if (retValuedup > 0) { if (retValuedup > 0) {
log.info("request already existed for msg -> " + hdrs[0]); log.info("request already existed for msg -> " + hdrs[0]);
return true; return true;
@ -390,6 +399,9 @@ public class RequestEMailProcessor extends SvrProcess
+ " ) " + " ) "
+ " ) "; + " ) ";
PreparedStatement pstmtupd = null; PreparedStatement pstmtupd = null;
ResultSet rsupd = null;
try
{
pstmtupd = DB.prepareStatement (sqlupd, null); pstmtupd = DB.prepareStatement (sqlupd, null);
pstmtupd.setInt(1, getAD_Client_ID()); pstmtupd.setInt(1, getAD_Client_ID());
pstmtupd.setString(2, fromAddress); pstmtupd.setString(2, fromAddress);
@ -398,12 +410,19 @@ public class RequestEMailProcessor extends SvrProcess
pstmtupd.setString(5, msg.getSubject()); pstmtupd.setString(5, msg.getSubject());
pstmtupd.setString(6, fromAddress); pstmtupd.setString(6, fromAddress);
pstmtupd.setString(7, msg.getSubject()); pstmtupd.setString(7, msg.getSubject());
ResultSet rsupd = pstmtupd.executeQuery (); rsupd = pstmtupd.executeQuery ();
if (rsupd.next ()) if (rsupd.next ())
request_upd = rsupd.getInt(1); request_upd = rsupd.getInt(1);
rsupd.close (); }
pstmtupd.close (); catch (SQLException e)
pstmtupd = null; {
throw e;
}
finally
{
DB.close(rsupd,pstmtupd);
rsupd = null;pstmtupd = null;
}
if (request_upd > 0) { if (request_upd > 0) {
log.info("msg -> " + hdrs[0] + " is an answer for req " + request_upd); log.info("msg -> " + hdrs[0] + " is an answer for req " + request_upd);
return updateRequest(request_upd, msg); return updateRequest(request_upd, msg);
@ -443,15 +462,25 @@ public class RequestEMailProcessor extends SvrProcess
+ " WHERE UPPER (email) = UPPER (?) " + " WHERE UPPER (email) = UPPER (?) "
+ " AND ad_client_id = ?"; + " AND ad_client_id = ?";
PreparedStatement pstmtu = null; PreparedStatement pstmtu = null;
ResultSet rsu = null;
try
{
pstmtu = DB.prepareStatement (sqlu, null); pstmtu = DB.prepareStatement (sqlu, null);
pstmtu.setString(1, fromAddress); pstmtu.setString(1, fromAddress);
pstmtu.setInt(2, getAD_Client_ID()); pstmtu.setInt(2, getAD_Client_ID());
ResultSet rsu = pstmtu.executeQuery (); rsu = pstmtu.executeQuery ();
if (rsu.next ()) if (rsu.next ())
retValueu = rsu.getInt(1); retValueu = rsu.getInt(1);
rsu.close (); }
pstmtu.close (); catch(SQLException e)
pstmtu = null; {
throw e;
}
finally
{
DB.close (rsu,pstmtu);
rsu = null;pstmtu = null;
}
if (retValueu > 0) { if (retValueu > 0) {
req.setAD_User_ID(retValueu); req.setAD_User_ID(retValueu);
} else { } else {

View File

@ -116,6 +116,7 @@ public class RequestInvoice extends SvrProcess
.append("ORDER BY C_BPartner_ID"); .append("ORDER BY C_BPartner_ID");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql.toString(), get_TrxName()); pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
@ -127,7 +128,7 @@ public class RequestInvoice extends SvrProcess
pstmt.setInt (index++, p_R_Category_ID); pstmt.setInt (index++, p_R_Category_ID);
if (p_C_BPartner_ID != 0) if (p_C_BPartner_ID != 0)
pstmt.setInt (index++, p_C_BPartner_ID); pstmt.setInt (index++, p_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
int oldC_BPartner_ID = 0; int oldC_BPartner_ID = 0;
while (rs.next ()) while (rs.next ())
{ {
@ -145,22 +146,15 @@ public class RequestInvoice extends SvrProcess
} }
invoiceDone(); invoiceDone();
// //
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log (Level.SEVERE, sql.toString(), e); log.log (Level.SEVERE, sql.toString(), e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// R_Category_ID // R_Category_ID

View File

@ -167,11 +167,12 @@ public class SendMailText extends SvrProcess
+ " AND u.EMail IS NOT NULL" + " AND u.EMail IS NOT NULL"
+ " AND ci.R_InterestArea_ID=?"; + " AND ci.R_InterestArea_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, m_R_InterestArea_ID); pstmt.setInt(1, m_R_InterestArea_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
Boolean ok = sendIndividualMail (rs.getString(1), rs.getInt(3), unsubscribe); Boolean ok = sendIndividualMail (rs.getString(1), rs.getInt(3), unsubscribe);
@ -182,24 +183,18 @@ public class SendMailText extends SvrProcess
else else
m_errors++; m_errors++;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, sql, ex); log.log(Level.SEVERE, sql, ex);
} }
// Clean Up // Clean Up
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close(); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
m_ia = null; m_ia = null;
} // sendInterestArea } // sendInterestArea
@ -217,11 +212,12 @@ public class SendMailText extends SvrProcess
+ " AND u.EMail IS NOT NULL" + " AND u.EMail IS NOT NULL"
+ " AND bp.C_BP_Group_ID=?"; + " AND bp.C_BP_Group_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, m_C_BP_Group_ID); pstmt.setInt(1, m_C_BP_Group_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
Boolean ok = sendIndividualMail (rs.getString(1), rs.getInt(3), null); Boolean ok = sendIndividualMail (rs.getString(1), rs.getInt(3), null);
@ -232,24 +228,18 @@ public class SendMailText extends SvrProcess
else else
m_errors++; m_errors++;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, sql, ex); log.log(Level.SEVERE, sql, ex);
} }
// Clean Up // Clean Up
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close(); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
} // sendBPGroup } // sendBPGroup
/** /**

View File

@ -51,6 +51,8 @@ public class SynchronizeTerminology extends SvrProcess
{ {
//TODO Error handling //TODO Error handling
String sql = null; String sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try { try {
int no; int no;
Trx trx = Trx.get(get_TrxName(), false); Trx trx = Trx.get(get_TrxName(), false);
@ -60,8 +62,8 @@ public class SynchronizeTerminology extends SvrProcess
+"(SELECT 1 FROM AD_ELEMENT e " +"(SELECT 1 FROM AD_ELEMENT e "
+" WHERE UPPER(c.ColumnName)=UPPER(e.ColumnName))" +" WHERE UPPER(c.ColumnName)=UPPER(e.ColumnName))"
+" AND c.isActive = 'Y'"; +" AND c.isActive = 'Y'";
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next()){ while (rs.next()){
String columnName = rs.getString(1); String columnName = rs.getString(1);
String name = rs.getString(2); String name = rs.getString(2);
@ -74,8 +76,8 @@ public class SynchronizeTerminology extends SvrProcess
elem.setPrintName(name); elem.setPrintName(name);
elem.saveEx(); elem.saveEx();
} }
pstmt.close(); DB.close(rs, pstmt);
rs.close(); rs = null; pstmt = null;
trx.commit(true); trx.commit(true);
// Create Elements for Process Parameters which are centrally maintained // Create Elements for Process Parameters which are centrally maintained
/* IDEMPIERE 109 - this create unwanted Element /* IDEMPIERE 109 - this create unwanted Element
@ -844,6 +846,12 @@ public class SynchronizeTerminology extends SvrProcess
log.log (Level.SEVERE, "@Failed@: "+e.getLocalizedMessage(), e); log.log (Level.SEVERE, "@Failed@: "+e.getLocalizedMessage(), e);
throw e; throw e;
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "@OK@"; return "@OK@";
} }

View File

@ -130,10 +130,11 @@ public class TreeMaintenance extends SvrProcess
// //
boolean ok = true; boolean ok = true;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int Node_ID = rs.getInt(1); int Node_ID = rs.getInt(1);
@ -157,23 +158,16 @@ public class TreeMaintenance extends SvrProcess
log.log(Level.SEVERE, "Could not add to " + tree + " Node_ID=" + Node_ID); log.log(Level.SEVERE, "Could not add to " + tree + " Node_ID=" + Node_ID);
} }
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "verifyTree", e); log.log(Level.SEVERE, "verifyTree", e);
ok = false; ok = false;
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
StringBuilder msglog = new StringBuilder().append(tree.getName()).append(" Inserted"); StringBuilder msglog = new StringBuilder().append(tree.getName()).append(" Inserted");

View File

@ -118,29 +118,23 @@ public class MTableAccess extends X_AD_Table_Access
{ {
String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?"; String sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getAD_Table_ID()); pstmt.setInt(1, getAD_Table_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
m_tableName = rs.getString(1); m_tableName = rs.getString(1);
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "getTableName", e); log.log(Level.SEVERE, "getTableName", e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// Get Clear Text // Get Clear Text

View File

@ -278,17 +278,19 @@ public class MTemplate extends X_CM_Template
int[] AdCats = null; int[] AdCats = null;
String sql = "SELECT count(*) FROM CM_Template_AD_Cat WHERE CM_Template_ID=?"; String sql = "SELECT count(*) FROM CM_Template_AD_Cat WHERE CM_Template_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
int numberAdCats = 0; int numberAdCats = 0;
pstmt = DB.prepareStatement (sql, get_TrxName ()); pstmt = DB.prepareStatement (sql, get_TrxName ());
pstmt.setInt (1, get_ID ()); pstmt.setInt (1, get_ID ());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
{ {
numberAdCats = rs.getInt (1); numberAdCats = rs.getInt (1);
} }
rs.close (); DB.close(rs, pstmt);
rs = null; pstmt = null;
AdCats = new int[numberAdCats]; AdCats = new int[numberAdCats];
int i = 0; int i = 0;
sql = "SELECT CM_Ad_Cat_ID FROM CM_Template_AD_Cat WHERE CM_Template_ID=?"; sql = "SELECT CM_Ad_Cat_ID FROM CM_Template_AD_Cat WHERE CM_Template_ID=?";
@ -300,23 +302,16 @@ public class MTemplate extends X_CM_Template
AdCats[i] = rs.getInt (1); AdCats[i] = rs.getInt (1);
i++; i++;
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log (Level.SEVERE, sql, ex); log.log (Level.SEVERE, sql, ex);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
} }
catch (SQLException ex1)
{
}
pstmt = null;
if (AdCats != null && AdCats.length > 0) if (AdCats != null && AdCats.length > 0)
{ {
MAd[] returnAds = new MAd[AdCats.length]; MAd[] returnAds = new MAd[AdCats.length];

View File

@ -117,34 +117,29 @@ public class MTimeExpense extends X_S_TimeExpense implements DocAction
// //
String sql = "SELECT * FROM S_TimeExpenseLine WHERE S_TimeExpense_ID=? ORDER BY Line"; String sql = "SELECT * FROM S_TimeExpenseLine WHERE S_TimeExpense_ID=? ORDER BY Line";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getS_TimeExpense_ID()); pstmt.setInt (1, getS_TimeExpense_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MTimeExpenseLine te = new MTimeExpenseLine(getCtx(), rs, get_TrxName()); MTimeExpenseLine te = new MTimeExpenseLine(getCtx(), rs, get_TrxName());
te.setC_Currency_Report_ID(C_Currency_ID); te.setC_Currency_Report_ID(C_Currency_ID);
list.add(te); list.add(te);
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, "getLines", ex); log.log(Level.SEVERE, "getLines", ex);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
// //
m_lines = new MTimeExpenseLine[list.size()]; m_lines = new MTimeExpenseLine[list.size()];
list.toArray(m_lines); list.toArray(m_lines);
@ -176,30 +171,25 @@ public class MTimeExpense extends X_S_TimeExpense implements DocAction
String sql = "SELECT M_Locator_ID FROM M_Locator " String sql = "SELECT M_Locator_ID FROM M_Locator "
+ "WHERE M_Warehouse_ID=? AND IsActive='Y' ORDER BY IsDefault DESC, Created"; + "WHERE M_Warehouse_ID=? AND IsActive='Y' ORDER BY IsDefault DESC, Created";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getM_Warehouse_ID()); pstmt.setInt (1, getM_Warehouse_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
m_M_Locator_ID = rs.getInt(1); m_M_Locator_ID = rs.getInt(1);
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, "getM_Locator_ID", ex); log.log(Level.SEVERE, "getM_Locator_ID", ex);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null;
}
catch (SQLException ex1)
{
}
pstmt = null; pstmt = null;
}
// //
return m_M_Locator_ID; return m_M_Locator_ID;
} // getM_Locator_ID } // getM_Locator_ID

View File

@ -167,21 +167,27 @@ public class MTree extends MTree_Base
String sql = "SELECT AD_Tree_ID, Name FROM AD_Tree " String sql = "SELECT AD_Tree_ID, Name FROM AD_Tree "
+ "WHERE AD_Client_ID=? AND TreeType=? AND IsActive='Y' AND IsAllNodes='Y' " + "WHERE AD_Client_ID=? AND TreeType=? AND IsActive='Y' AND IsAllNodes='Y' "
+ "ORDER BY IsDefault DESC, AD_Tree_ID"; + "ORDER BY IsDefault DESC, AD_Tree_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
pstmt.setString(2, TreeType); pstmt.setString(2, TreeType);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
AD_Tree_ID = rs.getInt(1); AD_Tree_ID = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return AD_Tree_ID; return AD_Tree_ID;
} // getDefaultAD_Tree_ID } // getDefaultAD_Tree_ID
@ -225,18 +231,20 @@ public class MTree extends MTree_Base
} }
log.finest(sql.toString()); log.finest(sql.toString());
// The Node Loop // The Node Loop
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
// load Node details - addToTree -> getNodeDetail // load Node details - addToTree -> getNodeDetail
getNodeDetails(); getNodeDetails();
// //
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
int idx = 1; int idx = 1;
if (AD_User_ID != -1 && getTreeType().equals(TREETYPE_Menu)) // IDEMPIERE 329 - nmicoud if (AD_User_ID != -1 && getTreeType().equals(TREETYPE_Menu)) // IDEMPIERE 329 - nmicoud
pstmt.setInt(idx++, AD_User_ID); pstmt.setInt(idx++, AD_User_ID);
pstmt.setInt(idx++, getAD_Tree_ID()); pstmt.setInt(idx++, getAD_Tree_ID());
// Get Tree & Bar // Get Tree & Bar
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
m_root = new MTreeNode (0, 0, getName(), getDescription(), 0, true, null, false, null); m_root = new MTreeNode (0, 0, getName(), getDescription(), 0, true, null, false, null);
while (rs.next()) while (rs.next())
{ {
@ -250,8 +258,6 @@ public class MTree extends MTree_Base
else else
addToTree (node_ID, parent_ID, seqNo, onBar); // calls getNodeDetail addToTree (node_ID, parent_ID, seqNo, onBar); // calls getNodeDetail
} }
rs.close();
pstmt.close();
// //
//closing the rowset will also close connection for oracle rowset implementation //closing the rowset will also close connection for oracle rowset implementation
//m_nodeRowSet.close(); //m_nodeRowSet.close();
@ -264,6 +270,12 @@ public class MTree extends MTree_Base
m_nodeRowSet = null; m_nodeRowSet = null;
m_nodeIdMap = null; m_nodeIdMap = null;
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Done with loading - add remainder from buffer // Done with loading - add remainder from buffer
if (m_buffer.size() != 0) if (m_buffer.size() != 0)

View File

@ -48,30 +48,24 @@ public class MTree_Node extends X_AD_TreeNode
MTree_Node retValue = null; MTree_Node retValue = null;
String sql = "SELECT * FROM AD_TreeNode WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNode WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_Node (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_Node (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -48,30 +48,24 @@ public class MTree_NodeBP extends X_AD_TreeNodeBP
MTree_NodeBP retValue = null; MTree_NodeBP retValue = null;
String sql = "SELECT * FROM AD_TreeNodeBP WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNodeBP WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_NodeBP (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_NodeBP (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, "get", e); s_log.log(Level.SEVERE, "get", e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -51,31 +51,25 @@ public class MTree_NodeCMC extends X_AD_TreeNodeCMC
ArrayList<MTree_NodeCMC> list = new ArrayList<MTree_NodeCMC>(); ArrayList<MTree_NodeCMC> list = new ArrayList<MTree_NodeCMC>();
String sql = "SELECT * FROM AD_TreeNodeCMC WHERE AD_Tree_ID=? ORDER BY Node_ID"; String sql = "SELECT * FROM AD_TreeNodeCMC WHERE AD_Tree_ID=? ORDER BY Node_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, AD_Tree_ID); pstmt.setInt (1, AD_Tree_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
list.add (new MTree_NodeCMC (ctx, rs, trxName)); list.add (new MTree_NodeCMC (ctx, rs, trxName));
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
MTree_NodeCMC[] retValue = new MTree_NodeCMC[list.size ()]; MTree_NodeCMC[] retValue = new MTree_NodeCMC[list.size ()];
@ -95,30 +89,24 @@ public class MTree_NodeCMC extends X_AD_TreeNodeCMC
MTree_NodeCMC retValue = null; MTree_NodeCMC retValue = null;
String sql = "SELECT * FROM AD_TreeNodeCMC WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNodeCMC WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_NodeCMC (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_NodeCMC (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, "get", e); s_log.log(Level.SEVERE, "get", e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -51,31 +51,25 @@ public class MTree_NodeCMS extends X_AD_TreeNodeCMS
ArrayList<MTree_NodeCMS> list = new ArrayList<MTree_NodeCMS>(); ArrayList<MTree_NodeCMS> list = new ArrayList<MTree_NodeCMS>();
String sql = "SELECT * FROM AD_TreeNodeCMS WHERE AD_Tree_ID=? ORDER BY Node_ID"; String sql = "SELECT * FROM AD_TreeNodeCMS WHERE AD_Tree_ID=? ORDER BY Node_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, AD_Tree_ID); pstmt.setInt (1, AD_Tree_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
list.add (new MTree_NodeCMS (ctx, rs, trxName)); list.add (new MTree_NodeCMS (ctx, rs, trxName));
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log (Level.SEVERE, sql, e); s_log.log (Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
MTree_NodeCMS[] retValue = new MTree_NodeCMS[list.size ()]; MTree_NodeCMS[] retValue = new MTree_NodeCMS[list.size ()];
@ -94,30 +88,24 @@ public class MTree_NodeCMS extends X_AD_TreeNodeCMS
MTree_NodeCMS retValue = null; MTree_NodeCMS retValue = null;
String sql = "SELECT * FROM AD_TreeNodeCMS WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNodeCMS WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_NodeCMS (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_NodeCMS (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, "get", e); s_log.log(Level.SEVERE, "get", e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -48,30 +48,24 @@ public class MTree_NodeMM extends X_AD_TreeNodeMM
MTree_NodeMM retValue = null; MTree_NodeMM retValue = null;
String sql = "SELECT * FROM AD_TreeNodeMM WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNodeMM WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_NodeMM (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_NodeMM (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, "get", e); s_log.log(Level.SEVERE, "get", e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -48,30 +48,24 @@ public class MTree_NodePR extends X_AD_TreeNodePR
MTree_NodePR retValue = null; MTree_NodePR retValue = null;
String sql = "SELECT * FROM AD_TreeNodePR WHERE AD_Tree_ID=? AND Node_ID=?"; String sql = "SELECT * FROM AD_TreeNodePR WHERE AD_Tree_ID=? AND Node_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, tree.get_TrxName()); pstmt = DB.prepareStatement (sql, tree.get_TrxName());
pstmt.setInt (1, tree.getAD_Tree_ID()); pstmt.setInt (1, tree.getAD_Tree_ID());
pstmt.setInt (2, Node_ID); pstmt.setInt (2, Node_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MTree_NodePR (tree.getCtx(), rs, tree.get_TrxName()); retValue = new MTree_NodePR (tree.getCtx(), rs, tree.get_TrxName());
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

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

View File

@ -95,6 +95,7 @@ public class MWarehousePrice extends X_RV_WarehousePrice
+ " - " + finalSQL); + " - " + finalSQL);
ArrayList<MWarehousePrice> list = new ArrayList<MWarehousePrice>(); ArrayList<MWarehousePrice> list = new ArrayList<MWarehousePrice>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(finalSQL, trxName); pstmt = DB.prepareStatement(finalSQL, trxName);
@ -109,25 +110,18 @@ public class MWarehousePrice extends X_RV_WarehousePrice
pstmt.setString(index++, UPC); pstmt.setString(index++, UPC);
if (SKU != null && SKU.length() > 0) if (SKU != null && SKU.length() > 0)
pstmt.setString(index++, SKU); pstmt.setString(index++, SKU);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MWarehousePrice(ctx, rs, trxName)); list.add(new MWarehousePrice(ctx, rs, trxName));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, finalSQL, e); s_log.log(Level.SEVERE, finalSQL, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// //
@ -191,31 +185,25 @@ public class MWarehousePrice extends X_RV_WarehousePrice
String sql = "SELECT * FROM RV_WarehousePrice " String sql = "SELECT * FROM RV_WarehousePrice "
+ "WHERE M_Product_ID=? AND M_PriceList_Version_ID=? AND M_Warehouse_ID=?"; + "WHERE M_Product_ID=? AND M_PriceList_Version_ID=? AND M_Warehouse_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, product.getM_Product_ID()); pstmt.setInt (1, product.getM_Product_ID());
pstmt.setInt(2, M_PriceList_Version_ID); pstmt.setInt(2, M_PriceList_Version_ID);
pstmt.setInt(3, M_Warehouse_ID); pstmt.setInt(3, M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MWarehousePrice(product.getCtx(), rs, trxName); retValue = new MWarehousePrice(product.getCtx(), rs, trxName);
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return retValue; return retValue;

View File

@ -71,29 +71,23 @@ public class MWebProjectDomain extends X_CM_WebProject_Domain
MWebProjectDomain thisWebProjectDomain = null; MWebProjectDomain thisWebProjectDomain = null;
String sql = "SELECT * FROM CM_WebProject_Domain WHERE lower(FQDN) LIKE ? ORDER by CM_WebProject_Domain_ID DESC"; String sql = "SELECT * FROM CM_WebProject_Domain WHERE lower(FQDN) LIKE ? ORDER by CM_WebProject_Domain_ID DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setString(1, ServerName); pstmt.setString(1, ServerName);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
thisWebProjectDomain = (new MWebProjectDomain(ctx, rs, trxName)); thisWebProjectDomain = (new MWebProjectDomain(ctx, rs, trxName));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
return thisWebProjectDomain; return thisWebProjectDomain;

View File

@ -133,14 +133,16 @@ public class ScheduleUtil
+ " AND DateTo >= ?" // #2 start + " AND DateTo >= ?" // #2 start
+ " AND DateFrom <= ?" // #3 end + " AND DateFrom <= ?" // #3 end
+ " AND IsActive='Y'"; + " AND IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
// log.fine( sql, "ID=" + S_Resource_ID + ", Start=" + m_startDate + ", End=" + m_endDate); // log.fine( sql, "ID=" + S_Resource_ID + ", Start=" + m_startDate + ", End=" + m_endDate);
PreparedStatement pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, m_S_Resource_ID); pstmt.setInt(1, m_S_Resource_ID);
pstmt.setTimestamp(2, m_startDate); pstmt.setTimestamp(2, m_startDate);
pstmt.setTimestamp(3, m_endDate); pstmt.setTimestamp(3, m_endDate);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
ma = new MAssignmentSlot (TimeUtil.getDay(rs.getTimestamp(2)), ma = new MAssignmentSlot (TimeUtil.getDay(rs.getTimestamp(2)),
@ -153,8 +155,6 @@ public class ScheduleUtil
else else
list.add(ma); list.add(ma);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -163,6 +163,13 @@ public class ScheduleUtil
Msg.getMsg (m_ctx, "ResourceUnAvailable"), e.toString(), Msg.getMsg (m_ctx, "ResourceUnAvailable"), e.toString(),
MAssignmentSlot.STATUS_UnAvailable); MAssignmentSlot.STATUS_UnAvailable);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (ma != null && !getAll) if (ma != null && !getAll)
return new MAssignmentSlot[] {ma}; return new MAssignmentSlot[] {ma};
@ -180,10 +187,10 @@ public class ScheduleUtil
Timestamp startDay = TimeUtil.getDay(m_startDate); Timestamp startDay = TimeUtil.getDay(m_startDate);
Timestamp endDay = TimeUtil.getDay(m_endDate); Timestamp endDay = TimeUtil.getDay(m_endDate);
// log.fine( sql, "Start=" + startDay + ", End=" + endDay); // log.fine( sql, "Start=" + startDay + ", End=" + endDay);
PreparedStatement pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setTimestamp(1, startDay); pstmt.setTimestamp(1, startDay);
pstmt.setTimestamp(2, endDay); pstmt.setTimestamp(2, endDay);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
Timestamp date = rs.getTimestamp(2); Timestamp date = rs.getTimestamp(2);
@ -194,8 +201,6 @@ public class ScheduleUtil
log.finer("- NonBusinessDay " + ma); log.finer("- NonBusinessDay " + ma);
list.add(ma); list.add(ma);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -204,6 +209,12 @@ public class ScheduleUtil
Msg.getMsg(m_ctx, "NonBusinessDay"), e.toString(), Msg.getMsg(m_ctx, "NonBusinessDay"), e.toString(),
MAssignmentSlot.STATUS_NonBusinessDay); MAssignmentSlot.STATUS_NonBusinessDay);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (ma != null && !getAll) if (ma != null && !getAll)
return new MAssignmentSlot[] {ma}; return new MAssignmentSlot[] {ma};
@ -217,9 +228,9 @@ public class ScheduleUtil
+ "WHERE S_ResourceType_ID=?"; + "WHERE S_ResourceType_ID=?";
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, m_S_ResourceType_ID); pstmt.setInt(1, m_S_ResourceType_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
m_typeName = rs.getString(1); m_typeName = rs.getString(1);
@ -259,8 +270,6 @@ public class ScheduleUtil
} // DaySlot } // DaySlot
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -269,6 +278,12 @@ public class ScheduleUtil
Msg.getMsg(m_ctx, "ResourceNotInSlotDay"), e.toString(), Msg.getMsg(m_ctx, "ResourceNotInSlotDay"), e.toString(),
MAssignmentSlot.STATUS_NonBusinessDay); MAssignmentSlot.STATUS_NonBusinessDay);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (ma != null && !getAll) if (ma != null && !getAll)
return new MAssignmentSlot[] {ma}; return new MAssignmentSlot[] {ma};
@ -281,11 +296,11 @@ public class ScheduleUtil
+ " AND IsActive='Y'"; + " AND IsActive='Y'";
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, trxName); pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, m_S_Resource_ID); pstmt.setInt(1, m_S_Resource_ID);
pstmt.setTimestamp(2, m_startDate); pstmt.setTimestamp(2, m_startDate);
pstmt.setTimestamp(3, m_endDate); pstmt.setTimestamp(3, m_endDate);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MResourceAssignment mAssignment = MResourceAssignment mAssignment =
@ -295,8 +310,6 @@ public class ScheduleUtil
break; break;
list.add(ma); list.add(ma);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -305,6 +318,12 @@ public class ScheduleUtil
Msg.translate(m_ctx, "S_R"), e.toString(), Msg.translate(m_ctx, "S_R"), e.toString(),
MAssignmentSlot.STATUS_NotConfirmed); MAssignmentSlot.STATUS_NotConfirmed);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (ma != null && !getAll) if (ma != null && !getAll)
return new MAssignmentSlot[] {ma}; return new MAssignmentSlot[] {ma};
@ -578,11 +597,13 @@ public class ScheduleUtil
+ " AND r.S_ResourceType_ID=rt.S_ResourceType_ID", + " AND r.S_ResourceType_ID=rt.S_ResourceType_ID",
"r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); "r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
// //
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, S_Resource_ID); pstmt.setInt(1, S_Resource_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
if (!"Y".equals(rs.getString(1))) // Active if (!"Y".equals(rs.getString(1))) // Active
@ -597,14 +618,18 @@ public class ScheduleUtil
} }
else else
m_isAvailable = false; m_isAvailable = false;
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
m_isAvailable = false; m_isAvailable = false;
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_S_Resource_ID = S_Resource_ID; m_S_Resource_ID = S_Resource_ID;
} // getBaseInfo } // getBaseInfo

View File

@ -1184,12 +1184,13 @@ public class DocumentEngine implements DocAction
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID" + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID"
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'" + " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
+ " AND l.AD_Reference_ID=? ORDER BY t.Name"; + " AND l.AD_Reference_ID=? ORDER BY t.Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, DocAction.AD_REFERENCE_ID); pstmt.setInt(1, DocAction.AD_REFERENCE_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
String value = rs.getString(1); String value = rs.getString(1);
@ -1202,13 +1203,17 @@ public class DocumentEngine implements DocAction
v_name.add(name); v_name.add(name);
v_description.add(description); v_description.add(description);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} }
/** /**

View File

@ -54,15 +54,16 @@ public class ProcessInfoUtil
String sql = "SELECT Result, ErrorMsg FROM AD_PInstance " String sql = "SELECT Result, ErrorMsg FROM AD_PInstance "
+ "WHERE AD_PInstance_ID=?" + "WHERE AD_PInstance_ID=?"
+ " AND Result IS NOT NULL"; + " AND Result IS NOT NULL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement (sql, pstmt = DB.prepareStatement (sql,
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null); ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null);
for (int noTry = 0; noTry < noRetry; noTry++) for (int noTry = 0; noTry < noRetry; noTry++)
{ {
pstmt.setInt(1, pi.getAD_PInstance_ID()); pstmt.setInt(1, pi.getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
// we have a result // we have a result
@ -76,16 +77,14 @@ public class ProcessInfoUtil
pi.setSummary(Msg.getMsg(Env.getCtx(), "Failure"), true); pi.setSummary(Msg.getMsg(Env.getCtx(), "Failure"), true);
} }
String Message = rs.getString(2); String Message = rs.getString(2);
rs.close();
pstmt.close();
// //
if (Message != null) if (Message != null)
pi.addSummary (" (" + Msg.parseTranslation(Env.getCtx(), Message) + ")"); pi.addSummary (" (" + Msg.parseTranslation(Env.getCtx(), Message) + ")");
// s_log.fine("setSummaryFromDB - " + Message); // s_log.fine("setSummaryFromDB - " + Message);
return; return;
} }
DB.close(rs);
rs.close(); rs = null;
// sleep // sleep
try try
{ {
@ -97,7 +96,6 @@ public class ProcessInfoUtil
s_log.log(Level.SEVERE, "Sleep Thread", ie); s_log.log(Level.SEVERE, "Sleep Thread", ie);
} }
} }
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -105,6 +103,11 @@ public class ProcessInfoUtil
pi.setSummary (e.getLocalizedMessage(), true); pi.setSummary (e.getLocalizedMessage(), true);
return; return;
} }
finally
{
DB.close(rs,pstmt);
rs = null;pstmt = null;
}
pi.setSummary (Msg.getMsg(Env.getCtx(), "Timeout"), true); pi.setSummary (Msg.getMsg(Env.getCtx(), "Timeout"), true);
} // setSummaryFromDB } // setSummaryFromDB
@ -119,23 +122,28 @@ public class ProcessInfoUtil
+ "FROM AD_PInstance_Log " + "FROM AD_PInstance_Log "
+ "WHERE AD_PInstance_ID=? " + "WHERE AD_PInstance_ID=? "
+ "ORDER BY Log_ID"; + "ORDER BY Log_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, pi.getAD_PInstance_ID()); pstmt.setInt(1, pi.getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()){ while (rs.next()){
// int Log_ID, int P_ID, Timestamp P_Date, BigDecimal P_Number, String P_Msg, AD_Table_ID, Record_ID // int Log_ID, int P_ID, Timestamp P_Date, BigDecimal P_Number, String P_Msg, AD_Table_ID, Record_ID
pi.addLog (rs.getInt(1), rs.getInt(2), rs.getTimestamp(3), rs.getBigDecimal(4), rs.getString(5), rs.getInt(6), rs.getInt(7)); pi.addLog (rs.getInt(1), rs.getInt(2), rs.getTimestamp(3), rs.getBigDecimal(4), rs.getString(5), rs.getInt(6), rs.getInt(7));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, "setLogFromDB", e); s_log.log(Level.SEVERE, "setLogFromDB", e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // getLogFromDB } // getLogFromDB
/** /**
@ -207,11 +215,13 @@ public class ProcessInfoUtil
+ " INNER JOIN AD_PInstance i ON (p.AD_PInstance_ID=i.AD_PInstance_ID) " + " INNER JOIN AD_PInstance i ON (p.AD_PInstance_ID=i.AD_PInstance_ID) "
+ "WHERE p.AD_PInstance_ID=? " + "WHERE p.AD_PInstance_ID=? "
+ "ORDER BY p.SeqNo"; + "ORDER BY p.SeqNo";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, pi.getAD_PInstance_ID()); pstmt.setInt(1, pi.getAD_PInstance_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
String ParameterName = rs.getString(1); String ParameterName = rs.getString(1);
@ -241,13 +251,17 @@ public class ProcessInfoUtil
if (pi.getAD_User_ID() == null) if (pi.getAD_User_ID() == null)
pi.setAD_User_ID(rs.getInt(12)); pi.setAD_User_ID(rs.getInt(12));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// //
ProcessInfoParameter[] pars = new ProcessInfoParameter[list.size()]; ProcessInfoParameter[] pars = new ProcessInfoParameter[list.size()];
list.toArray(pars); list.toArray(pars);

View File

@ -66,16 +66,14 @@ public class MReportColumnSet extends X_PA_ReportColumnSet
ArrayList<MReportColumn> list = new ArrayList<MReportColumn>(); ArrayList<MReportColumn> list = new ArrayList<MReportColumn>();
String sql = "SELECT * FROM PA_ReportColumn WHERE PA_ReportColumnSet_ID=? AND IsActive='Y' ORDER BY SeqNo"; String sql = "SELECT * FROM PA_ReportColumn WHERE PA_ReportColumnSet_ID=? AND IsActive='Y' ORDER BY SeqNo";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getPA_ReportColumnSet_ID()); pstmt.setInt(1, getPA_ReportColumnSet_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MReportColumn (getCtx(), rs, null)); list.add(new MReportColumn (getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -83,13 +81,8 @@ public class MReportColumnSet extends X_PA_ReportColumnSet
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
// //

View File

@ -84,16 +84,14 @@ public class MReportLine extends X_PA_ReportLine
ArrayList<MReportSource> list = new ArrayList<MReportSource>(); ArrayList<MReportSource> list = new ArrayList<MReportSource>();
String sql = "SELECT * FROM PA_ReportSource WHERE PA_ReportLine_ID=? AND IsActive='Y'"; String sql = "SELECT * FROM PA_ReportSource WHERE PA_ReportLine_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getPA_ReportLine_ID()); pstmt.setInt(1, getPA_ReportLine_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MReportSource (getCtx(), rs, null)); list.add(new MReportSource (getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -101,13 +99,8 @@ public class MReportLine extends X_PA_ReportLine
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
// //

View File

@ -68,16 +68,14 @@ public class MReportLineSet extends X_PA_ReportLineSet
+ "WHERE PA_ReportLineSet_ID=? AND IsActive='Y' " + "WHERE PA_ReportLineSet_ID=? AND IsActive='Y' "
+ "ORDER BY SeqNo"; + "ORDER BY SeqNo";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getPA_ReportLineSet_ID()); pstmt.setInt(1, getPA_ReportLineSet_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MReportLine (getCtx(), rs, get_TrxName())); list.add(new MReportLine (getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -85,13 +83,8 @@ public class MReportLineSet extends X_PA_ReportLineSet
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
// //

View File

@ -170,21 +170,27 @@ public class MReportTree
String sql = "SELECT AD_Tree_ID, Name FROM AD_Tree " String sql = "SELECT AD_Tree_ID, Name FROM AD_Tree "
+ "WHERE AD_Client_ID=? AND TreeType=? AND IsActive='Y' AND IsAllNodes='Y' " + "WHERE AD_Client_ID=? AND TreeType=? AND IsActive='Y' AND IsAllNodes='Y' "
+ "ORDER BY IsDefault DESC, AD_Tree_ID"; // assumes first is primary tree + "ORDER BY IsDefault DESC, AD_Tree_ID"; // assumes first is primary tree
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
pstmt.setString(2, m_TreeType); pstmt.setString(2, m_TreeType);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
AD_Tree_ID = rs.getInt(1); AD_Tree_ID = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return AD_Tree_ID; return AD_Tree_ID;
} // getDefaultAD_Tree_ID } // getDefaultAD_Tree_ID

View File

@ -245,19 +245,17 @@ public class TrialBalance extends SvrProcess
String sql = "SELECT StartDate, EndDate FROM C_Period WHERE C_Period_ID=?"; String sql = "SELECT StartDate, EndDate FROM C_Period WHERE C_Period_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, p_C_Period_ID); pstmt.setInt(1, p_C_Period_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
p_DateAcct_From = rs.getTimestamp(1); p_DateAcct_From = rs.getTimestamp(1);
p_DateAcct_To = rs.getTimestamp(2); p_DateAcct_To = rs.getTimestamp(2);
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -265,13 +263,8 @@ public class TrialBalance extends SvrProcess
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
} // setDateAcct } // setDateAcct

View File

@ -123,10 +123,12 @@ public class RModelData
// FillData // FillData
int index = 0; // rowset index int index = 0; // rowset index
m_rows.clear(); m_rows.clear();
Statement stmt = null;
ResultSet rs = null;
try try
{ {
Statement stmt = DB.createStatement(); stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(finalSQL); rs = stmt.executeQuery(finalSQL);
while (rs.next()) while (rs.next())
{ {
ArrayList<Object> row = new ArrayList<Object>(size); ArrayList<Object> row = new ArrayList<Object>(size);
@ -163,8 +165,6 @@ public class RModelData
} }
m_rows.add(row); m_rows.add(row);
} }
rs.close();
stmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -174,6 +174,12 @@ public class RModelData
log.log(Level.SEVERE, "Index=" + index + "," + rc, e); log.log(Level.SEVERE, "Index=" + index + "," + rc, e);
e.printStackTrace(); e.printStackTrace();
} }
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
process(); process();
} // query } // query

View File

@ -101,14 +101,26 @@ public class CCachedRowSet extends CachedRowSetImpl implements CachedRowSet
{ {
if (db.getName().equals(Database.DB_ORACLE)) if (db.getName().equals(Database.DB_ORACLE))
{ {
Statement stmt = conn.createStatement Statement stmt = null;
ResultSet rs = null;
try
{
stmt = conn.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
CachedRowSetImpl crs = new CachedRowSetImpl(); CachedRowSetImpl crs = new CachedRowSetImpl();
crs.populate(rs); crs.populate(rs);
rs.close();
stmt.close();
return crs; return crs;
} catch (SQLException e)
{
throw e;
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
} }
CachedRowSet crs = get(); CachedRowSet crs = get();
crs.setConcurrency(ResultSet.CONCUR_READ_ONLY); crs.setConcurrency(ResultSet.CONCUR_READ_ONLY);

View File

@ -194,11 +194,13 @@ public class GenericPaymentExport implements PaymentExport
+ " AND a.C_Region_ID=r.C_Region_ID(+)" + " AND a.C_Region_ID=r.C_Region_ID(+)"
+ " AND a.C_Country_ID=cc.C_Country_ID " + " AND a.C_Country_ID=cc.C_Country_ID "
+ "ORDER BY l.IsBillTo DESC"; + "ORDER BY l.IsBillTo DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID); pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
if (rs.next()) if (rs.next())
{ {
@ -233,13 +235,17 @@ public class GenericPaymentExport implements PaymentExport
if (bp[BP_REFNO] == null) if (bp[BP_REFNO] == null)
bp[BP_REFNO] = ""; bp[BP_REFNO] = "";
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, sql, e); s_log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return bp; return bp;
} // getBPartnerInfo } // getBPartnerInfo

View File

@ -476,9 +476,6 @@ public class WebInfo
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add (new MRequestType (m_ctx, rs, null)); list.add (new MRequestType (m_ctx, rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -511,16 +511,14 @@ public class MDDOrder extends X_DD_Order implements DocAction
"ORDER BY m.Created DESC"; "ORDER BY m.Created DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getDD_Order_ID()); pstmt.setInt(1, getDD_Order_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MMovement(getCtx(), rs, get_TrxName())); list.add(new MMovement(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -528,13 +526,8 @@ public class MDDOrder extends X_DD_Order implements DocAction
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
// //

View File

@ -81,6 +81,8 @@ public class CalloutAsset extends CalloutEngine {
{ {
Integer A_Depreciation_Table_Header_ID = (Integer)value; Integer A_Depreciation_Table_Header_ID = (Integer)value;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
if (A_Depreciation_Table_Header_ID != null){ if (A_Depreciation_Table_Header_ID != null){
@ -90,8 +92,8 @@ public class CalloutAsset extends CalloutEngine {
+A_Depreciation_Table_Header_ID +A_Depreciation_Table_Header_ID
+"'"; +"'";
PreparedStatement pstmt = DB.prepareStatement(SQL, null); // arhipac: compatibility pstmt = DB.prepareStatement(SQL, null); // arhipac: compatibility
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
// Charges - Set Context // Charges - Set Context
@ -99,8 +101,6 @@ public class CalloutAsset extends CalloutEngine {
mTab.setValue ("A_DEPRECIATION_MANUAL_PERIOD", rs.getString("A_Term")); mTab.setValue ("A_DEPRECIATION_MANUAL_PERIOD", rs.getString("A_Term"));
} }
rs.close();
pstmt.close();
} }
} }
catch (SQLException e) catch (SQLException e)
@ -108,6 +108,12 @@ public class CalloutAsset extends CalloutEngine {
log.info("PeriodType "+ e); log.info("PeriodType "+ e);
return e.getLocalizedMessage(); return e.getLocalizedMessage();
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return ""; return "";
} // Period Type } // Period Type
@ -131,6 +137,8 @@ public class CalloutAsset extends CalloutEngine {
{ {
Object A_Depreciation_ID = value; Object A_Depreciation_ID = value;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
String SQL = "SELECT DepreciationType " String SQL = "SELECT DepreciationType "
@ -138,8 +146,8 @@ public class CalloutAsset extends CalloutEngine {
+ "WHERE A_Depreciation_ID=" + "WHERE A_Depreciation_ID="
+ A_Depreciation_ID; + A_Depreciation_ID;
PreparedStatement pstmt = DB.prepareStatement(SQL, null); // arhipac: compatibility pstmt = DB.prepareStatement(SQL, null); // arhipac: compatibility
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
// Charges - Set Context // Charges - Set Context
@ -160,14 +168,18 @@ public class CalloutAsset extends CalloutEngine {
mTab.setValue ("A_Depreciation_Table_Header_ID", null); mTab.setValue ("A_Depreciation_Table_Header_ID", null);
} }
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.info("PeriodType "+ e); log.info("PeriodType "+ e);
return e.getLocalizedMessage(); return e.getLocalizedMessage();
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return ""; return "";
} // Period Type } // Period Type

View File

@ -202,7 +202,6 @@ public class AcctProcessor extends AdempiereServer
if (!ok) if (!ok)
countError[i]++; countError[i]++;
} }
rs.close();
} }
catch (Exception e) catch (Exception e)
{ {
@ -211,6 +210,8 @@ public class AcctProcessor extends AdempiereServer
finally finally
{ {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
} // for tableID } // for tableID

View File

@ -102,6 +102,7 @@ public class RequestProcessor extends AdempiereServer
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
sql += " AND R_RequestType_ID=?"; sql += " AND R_RequestType_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int count = 0; int count = 0;
int countEMails = 0; int countEMails = 0;
try try
@ -110,7 +111,7 @@ public class RequestProcessor extends AdempiereServer
pstmt.setInt (1, m_model.getAD_Client_ID()); pstmt.setInt (1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MRequest request = new MRequest (getCtx(), rs, null); MRequest request = new MRequest (getCtx(), rs, null);
@ -129,7 +130,6 @@ public class RequestProcessor extends AdempiereServer
count++; count++;
} }
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -137,7 +137,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("New Due #").append(count); m_summary.append("New Due #").append(count);
if (countEMails > 0) if (countEMails > 0)
@ -164,7 +166,7 @@ public class RequestProcessor extends AdempiereServer
pstmt.setInt (1, m_model.getAD_Client_ID()); pstmt.setInt (1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MRequest request = new MRequest (getCtx(), rs, null); MRequest request = new MRequest (getCtx(), rs, null);
@ -184,7 +186,6 @@ public class RequestProcessor extends AdempiereServer
count++; count++;
} }
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -192,7 +193,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("New Overdue #").append(count); m_summary.append("New Overdue #").append(count);
if (countEMails > 0) if (countEMails > 0)
@ -223,7 +226,7 @@ public class RequestProcessor extends AdempiereServer
pstmt.setInt(1, m_model.getAD_Client_ID()); pstmt.setInt(1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MRequest request = new MRequest (getCtx(), rs, null); MRequest request = new MRequest (getCtx(), rs, null);
@ -241,7 +244,6 @@ public class RequestProcessor extends AdempiereServer
request.saveEx(); request.saveEx();
count++; count++;
} }
rs.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -249,7 +251,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Alerts #").append(count); m_summary.append("Alerts #").append(count);
if (countEMails > 0) if (countEMails > 0)
@ -278,14 +282,13 @@ public class RequestProcessor extends AdempiereServer
pstmt.setInt(1, m_model.getAD_Client_ID()); pstmt.setInt(1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MRequest request = new MRequest (getCtx(), rs, null); MRequest request = new MRequest (getCtx(), rs, null);
if (escalate(request)) if (escalate(request))
count++; count++;
} }
rs.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -293,7 +296,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Escalated #").append(count).append(" - "); m_summary.append("Escalated #").append(count).append(" - ");
} // Esacalate } // Esacalate
@ -322,7 +327,7 @@ public class RequestProcessor extends AdempiereServer
pstmt.setInt(1, m_model.getAD_Client_ID()); pstmt.setInt(1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MRequest request = new MRequest (getCtx(), rs, null); MRequest request = new MRequest (getCtx(), rs, null);
@ -339,7 +344,6 @@ public class RequestProcessor extends AdempiereServer
count++; count++;
} }
} }
rs.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -347,7 +351,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Inactivity #").append(count); m_summary.append("Inactivity #").append(count);
if (countEMails > 0) if (countEMails > 0)
@ -430,12 +436,13 @@ public class RequestProcessor extends AdempiereServer
+ ") " + ") "
+ "ORDER BY R_Status_ID"; + "ORDER BY R_Status_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
MStatus status = null; MStatus status = null;
MStatus next = null; MStatus next = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MRequest r = new MRequest(getCtx(), rs, null); MRequest r = new MRequest(getCtx(), rs, null);
@ -456,7 +463,6 @@ public class RequestProcessor extends AdempiereServer
if (r.save()) if (r.save())
count++; count++;
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -464,7 +470,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Status Timeout #").append(count) m_summary.append("Status Timeout #").append(count)
@ -492,10 +500,11 @@ public class RequestProcessor extends AdempiereServer
int failure = 0; int failure = 0;
// //
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MRequest r = new MRequest (getCtx(), rs, null); MRequest r = new MRequest (getCtx(), rs, null);
@ -512,7 +521,6 @@ public class RequestProcessor extends AdempiereServer
else else
failure++; failure++;
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -520,7 +528,9 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Auto Change Request #").append(count); m_summary.append("Auto Change Request #").append(count);
@ -555,13 +565,14 @@ public class RequestProcessor extends AdempiereServer
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
sql += " AND R_RequestType_ID=?"; sql += " AND R_RequestType_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_model.getAD_Client_ID()); pstmt.setInt(1, m_model.getAD_Client_ID());
if (m_model.getR_RequestType_ID() != 0) if (m_model.getR_RequestType_ID() != 0)
pstmt.setInt(2, m_model.getR_RequestType_ID()); pstmt.setInt(2, m_model.getR_RequestType_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MRequest request = new MRequest (ctx, rs, null); MRequest request = new MRequest (ctx, rs, null);
@ -577,7 +588,6 @@ public class RequestProcessor extends AdempiereServer
else else
notFound++; notFound++;
} }
rs.close();
} }
catch (SQLException ex) catch (SQLException ex)
{ {
@ -585,9 +595,10 @@ public class RequestProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
} rs = null;
pstmt = null; pstmt = null;
}
// //
if (changed == 0 && notFound == 0) if (changed == 0 && notFound == 0)
m_summary.append("No unallocated Requests"); m_summary.append("No unallocated Requests");

View File

@ -103,13 +103,14 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND wfn.Action='Z'" // sleeping + " AND wfn.Action='Z'" // sleeping
+ " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))"; + " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int count = 0; int count = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, m_model.getAD_Client_ID()); pstmt.setInt (1, m_model.getAD_Client_ID());
pstmt.setInt (2, m_model.getAD_WorkflowProcessor_ID()); pstmt.setInt (2, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MWFActivity activity = new MWFActivity (getCtx(), rs, null); MWFActivity activity = new MWFActivity (getCtx(), rs, null);
@ -117,7 +118,6 @@ public class WorkflowProcessor extends AdempiereServer
// saves and calls MWFProcess.checkActivities(); // saves and calls MWFProcess.checkActivities();
count++; count++;
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -125,7 +125,9 @@ public class WorkflowProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Wakeup #").append(count).append (" - "); m_summary.append("Wakeup #").append(count).append (" - ");
} // wakeup } // wakeup
@ -144,12 +146,13 @@ public class WorkflowProcessor extends AdempiereServer
+ "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID AND wf.AD_WorkflowProcessor_ID=?" + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID AND wf.AD_WorkflowProcessor_ID=?"
+ " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)"; + " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int count = 0; int count = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt(1, m_model.getAD_WorkflowProcessor_ID()); pstmt.setInt(1, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MWFActivity activity = new MWFActivity (getCtx(), rs, null); MWFActivity activity = new MWFActivity (getCtx(), rs, null);
@ -162,7 +165,6 @@ public class WorkflowProcessor extends AdempiereServer
activity.saveEx(); activity.saveEx();
count++; count++;
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -170,7 +172,9 @@ public class WorkflowProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("DynPriority #").append(count).append (" - "); m_summary.append("DynPriority #").append(count).append (" - ");
@ -200,12 +204,13 @@ public class WorkflowProcessor extends AdempiereServer
int count = 0; int count = 0;
int countEMails = 0; int countEMails = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, m_model.getAlertOverPriority()); pstmt.setInt (1, m_model.getAlertOverPriority());
pstmt.setInt (2, m_model.getAD_WorkflowProcessor_ID()); pstmt.setInt (2, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MWFActivity activity = new MWFActivity (getCtx(), rs, null); MWFActivity activity = new MWFActivity (getCtx(), rs, null);
@ -216,8 +221,6 @@ public class WorkflowProcessor extends AdempiereServer
activity.saveEx(); activity.saveEx();
count++; count++;
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -225,7 +228,9 @@ public class WorkflowProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("OverPriority #").append(count); m_summary.append("OverPriority #").append(count);
if (countEMails > 0) if (countEMails > 0)
@ -250,13 +255,14 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND wfn.Action<>'Z'" // not sleeping + " AND wfn.Action<>'Z'" // not sleeping
+ " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))"; + " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
int count = 0; int count = 0;
int countEMails = 0; int countEMails = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt(1, m_model.getAD_WorkflowProcessor_ID()); pstmt.setInt(1, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
MWFActivity activity = new MWFActivity (getCtx(), rs, null); MWFActivity activity = new MWFActivity (getCtx(), rs, null);
@ -267,7 +273,6 @@ public class WorkflowProcessor extends AdempiereServer
activity.saveEx(); activity.saveEx();
count++; count++;
} }
rs.close ();
} }
catch (Exception e) catch (Exception e)
{ {
@ -275,7 +280,9 @@ public class WorkflowProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("EndWaitTime #").append(count); m_summary.append("EndWaitTime #").append(count);
@ -306,7 +313,7 @@ public class WorkflowProcessor extends AdempiereServer
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, m_model.getAD_WorkflowProcessor_ID()); pstmt.setInt (1, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
MWFActivity activity = new MWFActivity (getCtx(), rs, null); MWFActivity activity = new MWFActivity (getCtx(), rs, null);
@ -317,8 +324,6 @@ public class WorkflowProcessor extends AdempiereServer
activity.saveEx(); activity.saveEx();
count++; count++;
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -326,7 +331,9 @@ public class WorkflowProcessor extends AdempiereServer
} }
finally finally
{ {
DB.close(pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
m_summary.append("Inactivity #").append(count); m_summary.append("Inactivity #").append(count);
if (countEMails > 0) if (countEMails > 0)

View File

@ -380,13 +380,15 @@ public class Viewer extends CFrame
+ "WHERE c.AD_Table_ID=? AND c.IsKey='Y'" + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'"
+ " AND et.AD_Language=? " + " AND et.AD_Language=? "
+ "ORDER BY 3"; + "ORDER BY 3";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID()); pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());
if (trl) if (trl)
pstmt.setString(2, Env.getAD_Language(Env.getCtx())); pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
String tableName = rs.getString(2); String tableName = rs.getString(2);
@ -396,13 +398,17 @@ public class Viewer extends CFrame
name += "/" + poName; name += "/" + poName;
comboDrill.addItem(new ValueNamePair (tableName, name)); comboDrill.addItem(new ValueNamePair (tableName, name));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (comboDrill.getItemCount() == 1) if (comboDrill.getItemCount() == 1)
{ {
labelDrill.setVisible(false); labelDrill.setVisible(false);
@ -434,11 +440,13 @@ public class Viewer extends CFrame
+ "ORDER BY Name", + "ORDER BY Name",
"AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID); pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -446,13 +454,17 @@ public class Viewer extends CFrame
if (rs.getInt(1) == AD_PrintFormat_ID) if (rs.getInt(1) == AD_PrintFormat_ID)
selectValue = pp; selectValue = pp;
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// IDEMPIERE-297 - Check for Table Access and Window Access for New Report // IDEMPIERE-297 - Check for Table Access and Window Access for New Report
if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false)
&& MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT)) && MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT))
@ -1151,11 +1163,13 @@ public class Viewer extends CFrame
if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab")) if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab"))
sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?" sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?"
+ " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter; + " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Tab_ID); pstmt.setInt(1, AD_Tab_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
if (rs.next()) if (rs.next())
{ {
@ -1163,13 +1177,17 @@ public class Viewer extends CFrame
tableName = rs.getString(2); tableName = rs.getString(2);
} }
// //
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
GridField[] findFields = null; GridField[] findFields = null;
if (tableName != null) if (tableName != null)
@ -1250,19 +1268,25 @@ public class Viewer extends CFrame
ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>(); ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
ValueNamePair pp = null; ValueNamePair pp = null;
String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1"; String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new ValueNamePair (rs.getString(2), rs.getString(1))); list.add(new ValueNamePair (rs.getString(2), rs.getString(1)));
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (list.size() == 0) if (list.size() == 0)
{ {
ADialog.warn(m_WindowNo, this, "NoTranslation"); ADialog.warn(m_WindowNo, this, "NoTranslation");

View File

@ -366,11 +366,13 @@ public class VInOutInvoiceGen extends CPanel
int row = 0; int row = 0;
miniTable.setRowCount(row); miniTable.setRowCount(row);
// Execute // Execute
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
while (rs.next()) while (rs.next())
{ {
@ -387,13 +389,17 @@ public class VInOutInvoiceGen extends CPanel
// prepare next // prepare next
row++; row++;
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// //
miniTable.autoSize(); miniTable.autoSize();
// statusBar.setStatusDB(String.valueOf(miniTable.getRowCount())); // statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));

View File

@ -143,24 +143,20 @@ public abstract class CreateFromInvoice extends CreateFrom
+ "WHERE inv.M_RMA_ID=r.M_RMA_ID AND inv.DocStatus IN ('CO', 'CL'))"; + "WHERE inv.M_RMA_ID=r.M_RMA_ID AND inv.DocStatus IN ('CO', 'CL'))";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try { try {
pstmt = DB.prepareStatement(sqlStmt, null); pstmt = DB.prepareStatement(sqlStmt, null);
pstmt.setInt(1, C_BPartner_ID); pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
} }
rs.close();
} catch (SQLException e) { } catch (SQLException e) {
log.log(Level.SEVERE, sqlStmt.toString(), e); log.log(Level.SEVERE, sqlStmt.toString(), e);
} finally{ } finally{
if (pstmt != null) { DB.close(rs, pstmt);
try { rs = null;
pstmt.close(); pstmt = null;
} catch (Exception ex) {
log.severe("Could not close prepared statement");
}
}
} }
return list; return list;

View File

@ -98,24 +98,20 @@ public abstract class CreateFromShipment extends CreateFrom
+ "AND rl.M_InOutLine_ID IS NOT NULL)"; + "AND rl.M_InOutLine_ID IS NOT NULL)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try { try {
pstmt = DB.prepareStatement(sqlStmt, null); pstmt = DB.prepareStatement(sqlStmt, null);
pstmt.setInt(1, C_BPartner_ID); pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
} }
rs.close();
} catch (SQLException e) { } catch (SQLException e) {
log.log(Level.SEVERE, sqlStmt.toString(), e); log.log(Level.SEVERE, sqlStmt.toString(), e);
} finally{ } finally{
if (pstmt != null) { DB.close(rs, pstmt);
try { rs = null;
pstmt.close(); pstmt = null;
} catch (Exception ex) {
log.severe("Could not close prepared statement");
}
}
} }
return list; return list;

View File

@ -123,11 +123,12 @@ public class RequestOrderRefTag extends TagSupport
+ "WHERE C_BPartner_ID=? " + "WHERE C_BPartner_ID=? "
+ "ORDER BY CreatedBy DESC"; + "ORDER BY CreatedBy DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID); pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
o = new option (rs.getString(1)); o = new option (rs.getString(1));
@ -137,9 +138,6 @@ public class RequestOrderRefTag extends TagSupport
o.addElement(Util.maskHTML(display)); o.addElement(Util.maskHTML(display));
list.add(o); list.add(o);
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -147,16 +145,10 @@ public class RequestOrderRefTag extends TagSupport
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }
// Return to Array and return // Return to Array and return
option options[] = new option [list.size()]; option options[] = new option [list.size()];
list.toArray(options); list.toArray(options);

View File

@ -93,20 +93,18 @@ public class RequestTypeTag extends TagSupport
+ "WHERE AD_Client_ID=? AND IsActive='Y' AND IsSelfService='Y' " + "WHERE AD_Client_ID=? AND IsActive='Y' AND IsSelfService='Y' "
+ "ORDER BY IsDefault DESC, Name"; + "ORDER BY IsDefault DESC, Name";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
option o = new option (rs.getString(1)); option o = new option (rs.getString(1));
o.addElement(Util.maskHTML(rs.getString(2))); o.addElement(Util.maskHTML(rs.getString(2)));
list.add(o); list.add(o);
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -114,13 +112,8 @@ public class RequestTypeTag extends TagSupport
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null; pstmt = null;
} }

View File

@ -223,14 +223,14 @@ public class CompiereService {
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
loginInfo = rs.getString(1); loginInfo = rs.getString(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null;
pstmt = null;
} }
// not verified // not verified