Merge 49f33f4950c9

This commit is contained in:
Heng Sin Low 2013-02-20 17:56:44 +08:00
commit d8e7b6ee67
178 changed files with 2454 additions and 2799 deletions

View File

@ -90,9 +90,6 @@ public class CalloutGLJournal extends CalloutEngine
rs = pstmt.executeQuery();
if (rs.next())
C_Period_ID = rs.getInt(1);
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException e)
{
@ -102,6 +99,8 @@ public class CalloutGLJournal extends CalloutEngine
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (C_Period_ID != 0)
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 "
+ "WHERE M_Product_ID=?" // 1
+ " AND M_Locator_ID=?"; // 2
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_Locator_ID);
if (M_AttributeSetInstance_ID != 0)
pstmt.setInt(3, M_AttributeSetInstance_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
bd = rs.getBigDecimal(1);
@ -174,14 +175,19 @@ public class CalloutInventory extends CalloutEngine
// for example when the locator has never stored a particular product.
return new BigDecimal(0);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
throw new Exception(e.getLocalizedMessage());
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return new BigDecimal(0);
}

View File

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

View File

@ -44,67 +44,73 @@ import org.compiere.util.DB;
public class ApplyMigrationScripts extends SvrProcess {
/** Logger */
private static CLogger log = CLogger
.getCLogger(ApplyMigrationScripts.class);
private static CLogger log = CLogger.getCLogger(ApplyMigrationScripts.class);
@Override
protected String doIt() throws Exception {
// TODO Auto-generated method stub
log.info("Applying migrations scripts");
StringBuilder sql = new StringBuilder()
.append("select ad_migrationscript_id, script, name from ad_migrationscript where isApply = 'Y' and status = 'IP' order by name, created");
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), this.get_TrxName());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
byte[] scriptArray = rs.getBytes(2);
int seqID = rs.getInt(1);
boolean execOk = true;
try {
StringBuilder tmpSql = new StringBuilder(new String(scriptArray));
if (tmpSql.length() > 0) {
log.info("Executing script " + rs.getString(3));
execOk = executeScript(tmpSql.toString(), rs.getString(3));
System.out.println();
}
} catch (SQLException e) {
execOk = false;
e.printStackTrace();
StringBuilder msglog = new StringBuilder("Script: ").append(rs.getString(3)).append(" - ").append(e.getMessage());
log.saveError("Error", msglog.toString());
log.severe(e.getMessage());
} finally {
sql = new StringBuilder("UPDATE ad_migrationscript SET status = ? , isApply = 'N' WHERE ad_migrationscript_id = ? ");
pstmt = DB.prepareStatement(sql.toString(), this.get_TrxName());
if (execOk) {
pstmt.setString(1, "CO");
pstmt.setInt(2, seqID);
} else {
pstmt.setString(1, "ER");
pstmt.setInt(2, seqID);
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql.toString(), this.get_TrxName());
rs = pstmt.executeQuery();
while (rs.next()) {
byte[] scriptArray = rs.getBytes(2);
int seqID = rs.getInt(1);
boolean execOk = true;
try {
pstmt.executeUpdate();
if (!execOk) {
pstmt.close();
return null;
StringBuilder tmpSql = new StringBuilder(new String(scriptArray));
if (tmpSql.length() > 0) {
log.info("Executing script " + rs.getString(3));
execOk = executeScript(tmpSql.toString(), rs.getString(3));
System.out.println();
}
} catch (SQLException e) {
execOk = false;
e.printStackTrace();
StringBuilder msglog = new StringBuilder("Script: ").append(rs.getString(3)).append(" - ").append(e.getMessage());
log.saveError("Error", msglog.toString());
log.severe(e.getMessage());
} finally {
sql = new StringBuilder("UPDATE ad_migrationscript SET status = ? , isApply = 'N' WHERE ad_migrationscript_id = ? ");
PreparedStatement pstmtu = DB.prepareStatement(sql.toString(), this.get_TrxName());
if (execOk) {
pstmtu.setString(1, "CO");
pstmtu.setInt(2, seqID);
} else {
pstmtu.setString(1, "ER");
pstmtu.setInt(2, seqID);
}
try {
pstmtu.executeUpdate();
if (!execOk) {
return null;
}
} catch (SQLException e) {
e.printStackTrace();
StringBuilder msglog = new StringBuilder("Script: ").append(rs.getString(3)).append(" - ").append(e.getMessage());
log.saveError("Error", msglog.toString());
log.severe(e.getMessage());
} finally {
DB.close(pstmtu);
pstmtu = null;
}
}
}
} catch (SQLException e) {
throw e;
} finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
rs.close();
pstmt.close();
return null;
}
@Override
protected void prepare() {
// TODO Auto-generated method stub
}
@ -156,7 +162,8 @@ public class ApplyMigrationScripts extends SvrProcess {
log.saveError("Error", msglog.toString());
log.severe(e.getMessage());
} finally {
if (stmt != null)stmt.close();
DB.close(stmt);
stmt = null;
if(execOk)
conn.commit();
else

View File

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

View File

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

View File

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

View File

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

View File

@ -112,10 +112,11 @@ public class FactAcctReset extends SvrProcess
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')";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, get_TrxName());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
int AD_Table_ID = rs.getInt(1);
@ -125,22 +126,15 @@ public class FactAcctReset extends SvrProcess
else
reset (TableName);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//

View File

@ -264,10 +264,12 @@ public class ImportAccount extends SvrProcess
.append("FROM I_ElementValue ")
.append("WHERE I_IsImported='N'").append(clientCheck)
.append(" ORDER BY I_ElementValue_ID");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
while (rs.next())
{
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
rs.close();
pstmt.close();
}
catch (SQLException e)
{
throw new Exception ("create", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_ElementValue ")
@ -362,8 +368,8 @@ public class ImportAccount extends SvrProcess
int noParentUpdate = 0;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
//
String updateSQL = "UPDATE AD_TreeNode SET Parent_ID=?, SeqNo=? "
+ "WHERE AD_Tree_ID=? AND Node_ID=?";
@ -391,13 +397,17 @@ public class ImportAccount extends SvrProcess
if (no == 0)
log.info("Parent not found for " + rs.getString(5));
}
rs.close();
pstmt.close();
}
catch (SQLException 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@");
commitEx();
@ -444,20 +454,26 @@ public class ImportAccount extends SvrProcess
// **** Update Defaults
StringBuilder sql = new StringBuilder ("SELECT C_AcctSchema_ID FROM C_AcctSchema_Element ")
.append("WHERE C_Element_ID=?").append(clientCheck);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
updateDefaultAccounts (rs.getInt(1));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Default Account DEFAULT_ACCT
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("WHERE i.I_IsImported='Y' AND Processing='Y'")
.append(" AND i.C_ElementValue_ID IS NOT NULL AND C_Element_ID=?");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
int C_ElementValue_ID = rs.getInt(1);
@ -521,13 +539,17 @@ public class ImportAccount extends SvrProcess
log.log(Level.SEVERE, "Updated=" + no);
}
}
rs.close();
pstmt.close();
}
catch (SQLException 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_YES]), as.toString() + ": @Updated@");
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(ColumnName).append("=vc.C_ValidCombination_ID) ")
.append("WHERE x.C_AcctSchema_ID=").append(C_AcctSchema_ID);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
if (rs.next())
{
int C_ValidCombination_ID = rs.getInt(1);
@ -635,13 +659,17 @@ public class ImportAccount extends SvrProcess
} // for all default accounts
else
log.log(Level.SEVERE, "Account not found " + sql);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // updateDefaultAccount

View File

@ -329,11 +329,12 @@ public class ImportBankStatement extends SvrProcess
PreparedStatement pupdt = DB.prepareStatement(updateSql.toString(), get_TrxName());
PreparedStatement pstmtDuplicates = null;
ResultSet rs = null;
no = 0;
try
{
pstmtDuplicates = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmtDuplicates.executeQuery();
rs = pstmtDuplicates.executeQuery();
while (rs.next())
{
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();
no++;
}
rs.close();
pstmtDuplicates.close();
pupdt.close();
rs = null;
pstmtDuplicates = null;
pupdt = null;
}
catch(Exception e)
{
log.log(Level.SEVERE, "DetectDuplicates " + e.getMessage());
}
finally
{
DB.close(rs, pstmtDuplicates);
rs = null;pstmtDuplicates = null;
DB.close(pupdt);
pupdt = null;
}
if (no != 0)
log.info("Duplicates=" + no);
@ -374,7 +375,7 @@ public class ImportBankStatement extends SvrProcess
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
@ -508,18 +509,17 @@ public class ImportBankStatement extends SvrProcess
line = null;
}
// Close database connection
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
catch(Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported
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(" ORDER BY C_Currency_ID, C_Currency_ID_To, ValidFrom");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
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)
{
log.log(Level.SEVERE, sql.toString(), e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

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

View File

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

View File

@ -227,7 +227,6 @@ public class ImportInventory extends SvrProcess
if (no != 0)
log.warning ("No Location=" + no);
// Set M_Warehouse_ID
sql = new StringBuilder ("UPDATE I_Inventory i ")
.append("SET M_Warehouse_ID=(SELECT M_Warehouse_ID FROM M_Locator l WHERE i.M_Locator_ID=l.M_Locator_ID) ")
@ -243,6 +242,14 @@ public class ImportInventory extends SvrProcess
if (no != 0)
log.warning ("No Warehouse=" + no);
// IDEMPIERE-590 do not allow locator/wh from different org
sql = new StringBuilder ("UPDATE I_Inventory ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Locator not from Org, ' ")
.append("WHERE AD_Org_ID <> (SELECT AD_Org_ID FROM M_Warehouse WHERE M_Warehouse_ID = I_Inventory.M_Warehouse_ID")
.append(" AND I_IsImported<>'Y'").append (clientCheck).append(" )");
no = DB.executeUpdate (sql.toString (), get_TrxName());
if (no != 0)
log.warning ("Locator not from Org=" + no);
// Product
sql = new StringBuilder ("UPDATE I_Inventory i ")

View File

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

View File

@ -413,11 +413,12 @@ public class ImportPayment extends SvrProcess
MBankAccount account = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int noInsert = 0;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
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)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Payment ")

View File

@ -385,20 +385,26 @@ public class ImportProduct extends SvrProcess implements ImportProcess
// Get Default Tax Category
int C_TaxCategory_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
StringBuilder dbpst = new StringBuilder("SELECT C_TaxCategory_ID FROM C_TaxCategory WHERE IsDefault='Y'").append(clientCheck);
PreparedStatement pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
rs = pstmt.executeQuery();
if (rs.next())
C_TaxCategory_ID = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
throw new Exception ("TaxCategory", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("C_TaxCategory_ID=" + C_TaxCategory_ID);
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 ...");
sql = new StringBuilder ("SELECT * FROM I_Product WHERE I_IsImported='N'")
.append(clientCheck);
PreparedStatement pstmt_setImported = null;
PreparedStatement pstmt_insertProductPO = null;
try
{
/* Insert Product from Import
@ -468,7 +476,7 @@ public class ImportProduct extends SvrProcess implements ImportProcess
(sqlt, get_TrxName());
*/
// Insert Product from Import
PreparedStatement pstmt_insertProductPO = DB.prepareStatement
pstmt_insertProductPO = DB.prepareStatement
("INSERT INTO M_Product_PO (M_Product_ID,C_BPartner_ID, "
+ "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
+ "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());
// Set Imported = Y
PreparedStatement pstmt_setImported = DB.prepareStatement
pstmt_setImported = DB.prepareStatement
("UPDATE I_Product SET I_IsImported='Y', M_Product_ID=?, "
+ "Updated=SysDate, Processed='Y' WHERE I_Product_ID=?", get_TrxName());
//
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
while (rs.next())
{
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());
continue;
}
pstmt_updateProduct.close();
finally
{
DB.close(pstmt_updateProduct);
pstmt_updateProduct = null;
}
}
// Do we have PO Info
@ -604,7 +616,11 @@ public class ImportProduct extends SvrProcess implements ImportProcess
DB.executeUpdate(sql0.toString(), get_TrxName());
continue;
}
pstmt_updateProductPO.close();
finally
{
DB.close(pstmt_updateProductPO);
pstmt_updateProductPO = null;
}
}
if (no == 0) // Insert PO
{
@ -657,20 +673,19 @@ public class ImportProduct extends SvrProcess implements ImportProcess
//
commitEx();
} // 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)
{
}
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
sql = new StringBuilder ("UPDATE I_Product ")

View File

@ -265,6 +265,9 @@ public class ImportReportLine extends SvrProcess
.append("FROM I_ReportLine ")
.append("WHERE I_IsImported='N' AND PA_ReportLine_ID IS NULL")
.append(" AND I_IsImported='N'").append(clientCheck);
PreparedStatement pstmt_insertLine = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
// Insert ReportLine
@ -283,10 +286,10 @@ public class ImportReportLine extends SvrProcess
.append("WHERE PA_ReportLineSet_ID=? AND Name=? ") // #2..3
//jz + clientCheck, get_TrxName());
.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());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
while (rs.next())
{
int PA_ReportLineSet_ID = rs.getInt(1);
@ -311,15 +314,18 @@ public class ImportReportLine extends SvrProcess
continue;
}
}
rs.close();
pstmt.close();
//
pstmt_insertLine.close();
}
catch (SQLException 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)
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(" AND I_IsImported='N'").append(clientCheck);
PreparedStatement pstmt_insertSource = null;
PreparedStatement pstmt_deleteSource = null;
PreparedStatement pstmt_setImported = null;
try
{
// Insert ReportSource
@ -370,7 +379,7 @@ public class ImportReportLine extends SvrProcess
.append("WHERE I_ReportLine_ID=?")
.append(" AND I_IsImported='N'")
.append(clientCheck);
PreparedStatement pstmt_insertSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
pstmt_insertSource = DB.prepareStatement(dbpst.toString(), get_TrxName());
// Update ReportSource
//jz
@ -391,17 +400,17 @@ public class ImportReportLine extends SvrProcess
.append("WHERE C_ElementValue_ID IS NULL")
.append(" AND PA_ReportSource_ID=?")
.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
// Set Imported = Y
PreparedStatement pstmt_setImported = DB.prepareStatement
pstmt_setImported = DB.prepareStatement
("UPDATE I_ReportLine SET I_IsImported='Y',"
+ " PA_ReportSource_ID=?, "
+ " Updated=SysDate, Processed='Y' WHERE I_ReportLine_ID=?", get_TrxName());
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
while (rs.next())
{
int I_ReportLine_ID = rs.getInt(1);
@ -461,7 +470,11 @@ public class ImportReportLine extends SvrProcess
DB.executeUpdate(sql.toString(), get_TrxName());
continue;
}
pstmt_updateSource.close();
finally
{
DB.close(pstmt_updateSource);
pstmt_updateSource = null;
}
} // update source
// Set Imported to Y
@ -481,17 +494,19 @@ public class ImportReportLine extends SvrProcess
commitEx();
}
rs.close();
pstmt.close();
//
pstmt_insertSource.close();
//jz pstmt_updateSource.close();
pstmt_setImported.close();
//
}
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
sql = new StringBuilder ("UPDATE I_ReportLine ")

View File

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

View File

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

View File

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

View File

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

View File

@ -110,20 +110,26 @@ public class M_Product_BOM_Check extends SvrProcess
// Get count remaining on t_selection
int countno = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
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());
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(dbpst.toString(), get_TrxName());
rs = pstmt.executeQuery();
if (rs.next())
countno = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
throw new Exception ("count t_selection", e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("Count T_Selection =" + countno);
if (countno == 0)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -130,10 +130,11 @@ public class TreeMaintenance extends SvrProcess
//
boolean ok = true;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
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);
}
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "verifyTree", e);
ok = false;
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
StringBuilder msglog = new StringBuilder().append(tree.getName()).append(" Inserted");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2698,15 +2698,22 @@ public class MOrder extends X_C_Order implements DocAction
List<MOrderLine> result = new Vector<MOrderLine>();
Properties ctx = Env.getCtx();
MOrderLine line;
PreparedStatement ps = conn.prepareStatement(OrderLinesToAllocate);
ps.setInt(1, productId);
ResultSet rs = ps.executeQuery();
while(rs.next()) {
line = new MOrderLine(ctx, rs, trxName);
result.add(line);
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(OrderLinesToAllocate);
ps.setInt(1, productId);
rs = ps.executeQuery();
while(rs.next()) {
line = new MOrderLine(ctx, rs, trxName);
result.add(line);
}
} catch (SQLException e) {
throw e;
} finally {
DB.close(rs, ps);
rs = null; ps = null;
}
rs.close();
ps.close();
return(result);
}
@ -2735,23 +2742,28 @@ public class MOrder extends X_C_Order implements DocAction
"(QtyOrdered-QtyDelivered)>0 AND (QtyOrdered-QtyDelivered)>C_OrderLine.QtyAllocated)" +
"group by M_Product_ID " +
"order by M_Product_ID";
PreparedStatement ps = conn.prepareStatement(query1);
ps.setInt(1, WarehouseID);
ps.setInt(2, WarehouseID);
ResultSet rs = ps.executeQuery();
while(rs.next()) {
si = new StockInfo();
si.productId = rs.getInt(1);
si.qtyOnHand = rs.getBigDecimal(2);
si.qtyReserved = rs.getBigDecimal(3);
si.qtyAvailable = si.qtyOnHand.subtract(si.qtyReserved);
si.qtyAllocated = rs.getBigDecimal(4);
result.add(si);
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(query1);
ps.setInt(1, WarehouseID);
ps.setInt(2, WarehouseID);
rs = ps.executeQuery();
while(rs.next()) {
si = new StockInfo();
si.productId = rs.getInt(1);
si.qtyOnHand = rs.getBigDecimal(2);
si.qtyReserved = rs.getBigDecimal(3);
si.qtyAvailable = si.qtyOnHand.subtract(si.qtyReserved);
si.qtyAllocated = rs.getBigDecimal(4);
result.add(si);
}
} catch (SQLException e) {
throw e;
} finally {
DB.close(rs, ps);
rs = null; ps = null;
}
rs.close();
ps.close();
return(result);
}

View File

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

View File

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

View File

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

View File

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

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