IDEMPIERE-568 Review proper closing of JDBC statements and resultsets

This commit is contained in:
Richard Morales 2013-02-15 19:26:22 -05:00
parent 6d545ca059
commit 7838f1bf04
57 changed files with 835 additions and 492 deletions

View File

@ -182,10 +182,7 @@ public class Export extends SvrProcess
}
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) {/*ignored*/}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
@ -378,10 +375,7 @@ public class Export extends SvrProcess
}
} finally {
try {
if (rsEmbedded != null) rsEmbedded.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) { }
DB.close(rsEmbedded, pstmt);
rsEmbedded = null;
pstmt = null;
}

View File

@ -845,21 +845,27 @@ public abstract class Doc
{
String sql = "SELECT GL_Category_ID FROM C_DocType "
+ "WHERE AD_Client_ID=? AND DocBaseType=?";
PreparedStatement pstmt = null;
ResultSet rsDT = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, getAD_Client_ID());
pstmt.setString(2, m_DocumentType);
ResultSet rsDT = pstmt.executeQuery();
rsDT = pstmt.executeQuery();
if (rsDT.next())
m_GL_Category_ID = rsDT.getInt(1);
rsDT.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rsDT, pstmt);
rsDT = null;
pstmt = null;
}
}
// Still no GL_Category - get Default GL Category
@ -868,20 +874,26 @@ public abstract class Doc
String sql = "SELECT GL_Category_ID FROM GL_Category "
+ "WHERE AD_Client_ID=? "
+ "ORDER BY IsDefault DESC";
PreparedStatement pstmt = null;
ResultSet rsDT = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_Client_ID());
ResultSet rsDT = pstmt.executeQuery();
rsDT = pstmt.executeQuery();
if (rsDT.next())
m_GL_Category_ID = rsDT.getInt(1);
rsDT.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rsDT, pstmt);
rsDT = null;
pstmt = null;
}
}
//
if (m_GL_Category_ID == 0)

View File

@ -83,13 +83,13 @@ public class Doc_Production extends Doc
String sqlPL = "SELECT * FROM M_ProductionLine pl "
+ "WHERE pl.M_Production_ID=? "
+ "ORDER BY pl.Line";
PreparedStatement pstmtPL = null;
ResultSet rsPL = null;
try
{
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL, getTrxName());
pstmtPL = DB.prepareStatement(sqlPL, getTrxName());
pstmtPL.setInt(1,get_ID());
ResultSet rsPL = pstmtPL.executeQuery();
rsPL = pstmtPL.executeQuery();
while (rsPL.next())
{
X_M_ProductionLine line = new X_M_ProductionLine(getCtx(), rsPL, getTrxName());
@ -106,13 +106,17 @@ public class Doc_Production extends Doc
log.fine(docLine.toString());
list.add (docLine);
}
rsPL.close();
pstmtPL.close();
}
catch (Exception ee)
{
log.log(Level.SEVERE, sqlPL, ee);
}
finally
{
DB.close(rsPL, pstmtPL);
rsPL = null;
pstmtPL = null;
}
DocLine[] dl = new DocLine[list.size()];
list.toArray(dl);

View File

@ -353,11 +353,13 @@ public class CreateAdempiere
StringBuilder sb = new StringBuilder("CREATE TABLE ");
sb.append(tableName).append(" (");
ResultSet sourceColumns = null;
ResultSet sourcePK = null;
try
{
// Columns
boolean first = true;
ResultSet sourceColumns = md.getColumns(catalog, schema, table, null);
sourceColumns = md.getColumns(catalog, schema, table, null);
while (sourceColumns.next())
{
sb.append(first ? "" : ", ");
@ -431,10 +433,9 @@ public class CreateAdempiere
} // for all columns
sourceColumns.close();
// Primary Key
ResultSet sourcePK = md.getPrimaryKeys(catalog, schema, table);
sourcePK = md.getPrimaryKeys(catalog, schema, table);
// TABLE_CAT=null, TABLE_SCHEM=REFERENCE, TABLE_NAME=A_ASSET, COLUMN_NAME=A_ASSET_ID, KEY_SEQ=1, PK_NAME=A_ASSET_KEY
first = true;
boolean hasPK = false;
@ -451,7 +452,6 @@ public class CreateAdempiere
}
if (hasPK) // close constraint
sb.append(")"); // USING INDEX TABLESPACE INDX
sourcePK.close();
//
sb.append(")"); // close create table
}
@ -460,6 +460,13 @@ public class CreateAdempiere
log.log(Level.SEVERE, "createTable", ex);
return false;
}
finally
{
DB.close(sourceColumns);
DB.close(sourcePK);
sourceColumns = null;
sourcePK = null;
}
// Execute Create Table
if (!executeCommands(new String[]{sb.toString()}, m_conn, false, true))

View File

@ -89,11 +89,13 @@ public class CalloutUser extends CalloutEngine
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
if (rs.next())
{
@ -125,14 +127,18 @@ public class CalloutUser extends CalloutEngine
else
mTab.setValue("AD_User_ID", new Integer(contID));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return "";
} // bPartner
@ -160,20 +166,26 @@ public class CalloutUser extends CalloutEngine
//
String retValue = value;
String SQL = "SELECT FRIE_Name(?) FROM DUAL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, value);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getString(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // Frie_Name
@ -191,20 +203,26 @@ public class CalloutUser extends CalloutEngine
//
String retValue = value;
String SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, value);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getString(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // Frie_Value

View File

@ -195,10 +195,12 @@ class AcctViewerData
+ "WHERE EXISTS (SELECT * FROM AD_Column c"
+ " WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='Posted')"
+ " AND IsView='N'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int id = rs.getInt(1);
@ -211,13 +213,17 @@ class AcctViewerData
if (id == AD_Table_ID)
select = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (select != null)
cb.setSelectedItem(select);
} // fillTable
@ -232,20 +238,26 @@ class AcctViewerData
KeyNamePair pp = new KeyNamePair(0, "");
cb.addItem(pp);
String sql = "SELECT AD_Org_ID, Name FROM AD_Org WHERE AD_Client_ID=? ORDER BY Value";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
cb.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2)));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
} // fillOrg
/**
@ -264,19 +276,25 @@ class AcctViewerData
sql.append(MLookupFactory.getLookup_TableDirEmbed(language, columnName, "avd"))
.append(") FROM ").append(tableName).append(" avd WHERE avd.").append(selectSQL);
String retValue = "<" + selectSQL + ">";
Statement stmt = null;
ResultSet rs = null;
try
{
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql.toString());
stmt = DB.createStatement();
rs = stmt.executeQuery(sql.toString());
if (rs.next())
retValue = rs.getString(1);
rs.close();
stmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
return retValue;
} // getButtonText

View File

@ -635,24 +635,30 @@ public final class AEnv
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE 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())
{
TableName = rs.getString(1);
AD_Window_ID = rs.getInt(2);
PO_Window_ID = rs.getInt(3);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Nothing to Zoom to
if (TableName == null || AD_Window_ID == 0)
return;
@ -695,23 +701,29 @@ public final class AEnv
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT AD_Window_ID, PO_Window_ID FROM AD_Table WHERE TableName=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, TableName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
AD_Window_ID = rs.getInt(1);
PO_Window_ID = rs.getInt(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Nothing to Zoom to
if (AD_Window_ID == 0)
return;

View File

@ -2209,21 +2209,25 @@ public final class APanel extends CPanel
+ Env.getAD_Language(Env.getCtx())
+ "'"
+ " AND l.AD_Reference_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
PreparedStatement pstmt = DB
.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, AD_Reference_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next()) {
String value = rs.getString(1);
String name = rs.getString(2);
values.put(value, name);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, SQL, e);
}
finally{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Nothing to show or Record_ID
if (field.getValue() == null

View File

@ -233,23 +233,29 @@ public class ProcessParameter extends CDialog
// Create Fields
boolean hasFields = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_processInfo.getAD_Process_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
hasFields = true;
createField (rs);
}
rs.close();
pstmt.close();
}
catch(SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// both vectors the same?
if (m_mFields.size() != m_mFields2.size()

View File

@ -209,33 +209,27 @@ public class RecordInfo extends CDialog
+ "WHERE AD_Table_ID=? AND Record_ID=? "
+ "ORDER BY Updated DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, dse.AD_Table_ID);
pstmt.setInt (2, Record_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3),
rs.getString(4), rs.getString(5));
}
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

@ -208,19 +208,25 @@ public class VFileImport extends CPanel
pickFormat.addItem(s_none);
String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat",
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
pickFormat.addItem(rs.getString(1));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
pickFormat.setSelectedIndex(0);
pickFormat.addActionListener(this);
//

View File

@ -265,8 +265,6 @@ public class InfoGeneral extends Info
tableName = rs.getString(3);
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{

View File

@ -123,31 +123,25 @@ public class RecordAccessDialog extends CDialog
sql = "SELECT * FROM AD_Record_Access "
+ "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Table_ID);
pstmt.setInt(2, m_Record_ID);
pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("#" + m_recordAccesss.size());

View File

@ -576,10 +576,12 @@ public final class Calculator extends CDialog
String sql = "SELECT C_Currency_ID, ISO_Code FROM C_Currency "
+ "WHERE IsActive='Y' ORDER BY 2";
KeyNamePair defaultValue = null;
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())
{
int id = rs.getInt("C_Currency_ID");
@ -591,13 +593,17 @@ public final class Calculator extends CDialog
if (id == C_Currency_ID)
defaultValue = p;
}
rs.close();
stmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, "Calculator.loadCurrency", e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
// Set Defaults
if (defaultValue != null)

View File

@ -373,35 +373,29 @@ public final class VAccount extends JComponent
//
int C_ValidCombination_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_AcctSchema_ID);
pstmt.setString(2, text.toUpperCase());
pstmt.setString(3, text.toUpperCase());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
C_ValidCombination_ID = rs.getInt(1);
if (rs.next()) // only one
C_ValidCombination_ID = 0;
}
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;
}
// We have a Value

View File

@ -519,12 +519,14 @@ public final class VAccountDialog extends CDialog
{
log.fine("C_ValidCombination_ID=" + C_ValidCombination_ID);
String sql = "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_ValidCombination_ID);
pstmt.setInt(2, C_AcctSchema_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
if (f_Alias != null)
@ -549,13 +551,17 @@ public final class VAccountDialog extends CDialog
//
f_Description.setText (rs.getString("Description"));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadInfo
/**
@ -920,25 +926,32 @@ public final class VAccountDialog extends CDialog
log.fine("Check = " + sql.toString());
int IDvalue = 0;
String Alias = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_AD_Client_ID);
pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
IDvalue = rs.getInt(1);
Alias = rs.getString(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
IDvalue = 0;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("ID=" + IDvalue + ", Alias=" + Alias);
if (Alias == null)

View File

@ -309,10 +309,11 @@ public class VAssignment extends JComponent
+ " AND r.S_ResourceType_ID=rt.S_ResourceType_ID"
+ " and rt.C_UOM_ID=uom.C_UOM_ID", null);
//
ResultSet rs = null;
try
{
m_pstmt.setInt(1, S_ResourceAssignment_ID);
ResultSet rs = m_pstmt.executeQuery();
rs = m_pstmt.executeQuery();
if (rs.next())
{
StringBuilder sb = new StringBuilder(rs.getString(1));
@ -323,12 +324,16 @@ public class VAssignment extends JComponent
}
else
m_text.setText("<" + S_ResourceAssignment_ID + ">");
rs.close();
}
catch (Exception e)
{
log.log(Level.SEVERE, "", e);
}
finally
{
DB.close(rs);
rs = null;
}
} // setValue
/**

View File

@ -348,10 +348,12 @@ public class VAssignmentDialog extends CDialog
+ "FROM S_Resource r, S_ResourceType rt, C_UOM uom "
+ "WHERE r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID",
"r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
StringBuilder sb = new StringBuilder (rs.getString(2));
@ -363,13 +365,17 @@ public class VAssignmentDialog extends CDialog
KeyNamePair value = new KeyNamePair (rs.getInt(4), rs.getString(5).trim());
m_lookup.put(key, value);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
// Convert to Array
KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()];

View File

@ -312,25 +312,30 @@ public final class VButton extends CButton
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID"
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
+ " AND l.AD_Reference_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, AD_Reference_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String value = rs.getString(1);
String name = rs.getString(2);
m_values.put(value, name);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // readReference
/**

View File

@ -272,22 +272,28 @@ public class VColor extends CButton
//
String retValue = null;
String sql = "SELECT ImageURL FROM AD_Image WHERE AD_Image_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, AD_Image_ID.intValue());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
retValue = rs.getString(1);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // getURL

View File

@ -463,6 +463,7 @@ public class VLocator extends JComponent
//
int M_Locator_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(finalSql, null);
@ -474,30 +475,25 @@ public class VLocator extends JComponent
pstmt.setInt(index++, only_Product_ID);
pstmt.setInt(index++, only_Product_ID);
}
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
M_Locator_ID = rs.getInt(1);
if (rs.next())
M_Locator_ID = 0; // more than one
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, finalSql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
}
catch (SQLException ex1)
{
}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (M_Locator_ID == 0)
return false;

View File

@ -385,11 +385,13 @@ public class VLocatorDialog extends CDialog
//
String SQL = "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID "
+ "FROM M_Warehouse WHERE M_Warehouse_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_M_Warehouse_ID = rs.getInt(1);
@ -399,13 +401,17 @@ public class VLocatorDialog extends CDialog
m_AD_Client_ID = rs.getInt(5);
m_AD_Org_ID = rs.getInt(6);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // getWarehouseInfo
/**

View File

@ -226,11 +226,12 @@ public class WAcctViewerData
+ "WHERE EXISTS (SELECT * FROM AD_Column c"
+ " WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='Posted')"
+ " AND IsView='N'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
@ -245,13 +246,17 @@ public class WAcctViewerData
if (id == AD_Table_ID)
select = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (select != null)
;//cb.setSelectedItem(select);
@ -268,26 +273,30 @@ public class WAcctViewerData
KeyNamePair pp = new KeyNamePair(0, "");
cb.appendItem(pp.getName(), pp);
String sql = "SELECT AD_Org_ID, Name FROM AD_Org WHERE AD_Client_ID=? ORDER BY Value";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair key = new KeyNamePair(rs.getInt(1), rs.getString(2));
cb.appendItem(key.getName(), key);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // fillOrg
/**
@ -310,20 +319,26 @@ public class WAcctViewerData
.append(") FROM ").append(tableName).append(" avd WHERE avd.").append(selectSQL);
String retValue = "<" + selectSQL + ">";
Statement stmt = null;
ResultSet rs = null;
try
{
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql.toString());
stmt = DB.createStatement();
rs = stmt.executeQuery(sql.toString());
if (rs.next())
retValue = rs.getString(1);
rs.close();
stmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
return retValue;
} // getButtonText

View File

@ -156,24 +156,31 @@ public final class AEnv
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE 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())
{
TableName = rs.getString(1);
AD_Window_ID = rs.getInt(2);
PO_Window_ID = rs.getInt(3);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Nothing to Zoom to
if (TableName == null || AD_Window_ID == 0)
return;
@ -496,23 +503,29 @@ public final class AEnv
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT AD_Window_ID, PO_Window_ID FROM AD_Table WHERE TableName=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, TableName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
AD_Window_ID = rs.getInt(1);
PO_Window_ID = rs.getInt(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Nothing to Zoom to
if (AD_Window_ID == 0)
return;

View File

@ -222,19 +222,24 @@ public class ProcessParameterPanel extends Panel implements
// Create Fields
boolean hasFields = false;
Rows rows = new Rows();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_processInfo.getAD_Process_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next()) {
hasFields = true;
createField(rs, rows);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
finally{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
// both vectors the same?
if (m_mFields.size() != m_mFields2.size()

View File

@ -266,18 +266,20 @@ public class WAttributeGrid extends ADForm implements EventListener<Event>
// Add Access & Order
sql = MRole.getDefault().addAccessSQL (sql, "M_PriceList_Version", true, false) // fully qualidfied - RO
+ " ORDER BY M_PriceList_Version.Name";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pickPriceList.appendItem("", 0);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair kn = new KeyNamePair (rs.getInt(1), rs.getString(2));
pickPriceList.appendItem(kn.getName(), kn.getKey());
}
rs.close();
pstmt.close();
DB.close(rs, pstmt);
rs = null; pstmt = null;
// Warehouse
sql = "SELECT M_Warehouse_ID, Value || ' - ' || Name AS ValueName "
@ -295,13 +297,16 @@ public class WAttributeGrid extends ADForm implements EventListener<Event>
(rs.getInt("M_Warehouse_ID"), rs.getString("ValueName"));
pickWarehouse.appendItem(kn.getName(), kn.getKey());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // fillPicks
public void onEvent(Event e) throws Exception
@ -522,33 +527,27 @@ public class WAttributeGrid extends ADForm implements EventListener<Event>
sql = MRole.getDefault().addAccessSQL(sql, "M_Product",
MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null ;
int noProducts = 0;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
MProduct product = new MProduct(Env.getCtx(), rs, null);
addProduct (element, product);
noProducts++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}

View File

@ -235,21 +235,26 @@ public class WFileImport extends ADForm implements EventListener<Event>
String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat",
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
pickFormat.appendItem(rs.getString(1), rs.getString(1));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
pickFormat.setSelectedIndex(0);
pickFormat.addEventListener(Events.ON_SELECT, this);

View File

@ -155,9 +155,6 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
if (rs.next()) // only one
C_ValidCombination_ID = 0;
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{

View File

@ -113,10 +113,11 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
+ " AND r.S_ResourceType_ID=rt.S_ResourceType_ID"
+ " and rt.C_UOM_ID=uom.C_UOM_ID", null);
//
ResultSet rs = null;
try
{
m_pstmt.setInt(1, S_ResourceAssignment_ID);
ResultSet rs = m_pstmt.executeQuery();
rs = m_pstmt.executeQuery();
if (rs.next())
{
StringBuilder sb = new StringBuilder(rs.getString(1));
@ -127,12 +128,15 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
}
else
getComponent().setText("<" + S_ResourceAssignment_ID + ">");
rs.close();
}
catch (Exception e)
{
log.log(Level.SEVERE, "", e);
}
finally
{
DB.close(rs);
}
}

View File

@ -357,7 +357,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
int M_Locator_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(finalSql, null);
@ -372,7 +372,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
pstmt.setInt(index++, only_Product_ID);
}
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
@ -381,25 +381,17 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
if (rs.next())
M_Locator_ID = 0; // more than one
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, finalSql, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
}
catch (SQLException ex1)
{
}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (M_Locator_ID == 0)
return false;

View File

@ -709,12 +709,12 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
m_keyColumnName = m_columnName;
sql = new StringBuffer();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(query, null);
pstmt.setString(1, m_keyColumnName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
@ -724,25 +724,17 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
m_tableName = rs.getString(1);
sql.append("UPPER(").append(rs.getString(2)).append(") LIKE ").append(DB.TO_STRING(text));
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, query, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close();
}
catch (SQLException ex1)
{
}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
if (sql.length() == 0)
{

View File

@ -269,11 +269,13 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
int AD_Table_ID = 0;
String tableName = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, p_tableName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
@ -291,14 +293,18 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
tableName = rs.getString(3);
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Miminum check
if (m_queryColumns.size() == 0)
@ -340,9 +346,9 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
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();
while (rs.next())
{
String columnName = rs.getString(1);
@ -399,14 +405,18 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
else
log.finest("Not Added Column=" + columnName);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return false;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (list.size() == 0)
{

View File

@ -773,23 +773,28 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
log.finer(countSql);
m_count = -1;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(countSql, null);
pstmt = DB.prepareStatement(countSql, null);
setParameters (pstmt, true);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
m_count = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (Exception e)
{
log.log(Level.SEVERE, countSql, e);
m_count = -2;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (log.isLoggable(Level.FINE))
log.fine("#" + m_count + " - " + (System.currentTimeMillis()-start) + "ms");
@ -1079,32 +1084,26 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
//
String sql = "SELECT AD_Window_ID, PO_Window_ID FROM AD_Table WHERE TableName=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, tableName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_SO_Window_ID = rs.getInt(1);
m_PO_Window_ID = rs.getInt(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;
}
//

View File

@ -1861,19 +1861,25 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
// Execute Qusery
m_total = 999999;
Statement stmt = null;
ResultSet rs = null;
try
{
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(finalSQL);
stmt = DB.createStatement();
rs = stmt.executeQuery(finalSQL);
if (rs.next())
m_total = rs.getInt(1);
rs.close();
stmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, finalSQL, e);
}
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
MRole role = MRole.getDefault();
// No Records
/* if (m_total == 0 && alertZeroRecords)
@ -1920,9 +1926,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
StringBuilder retString = new StringBuilder(" M_Product_Category_ID IN (");
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 = null;
ResultSet rs = null;
try {
Statement stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
if(rs.getInt(1)==productCategoryId) {
subTreeRootParentId = rs.getInt(2);
@ -1931,8 +1939,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId))
.append(") ");
rs.close();
stmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
retString = new StringBuilder();
@ -1940,6 +1946,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
log.log(Level.SEVERE, sql, e);
retString = new StringBuilder();
}
finally{
DB.close(rs,stmt);
rs = null;
stmt = null;
}
return retString.toString();
} // getSubCategoryWhereClause

View File

@ -268,20 +268,26 @@ public class InfoSchedule extends Window implements EventListener<Event>
if (m_mAssignment.getS_Resource_ID() != 0)
{
String sql = "SELECT S_ResourceType_ID FROM S_Resource WHERE S_Resource_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_mAssignment.getS_Resource_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
S_ResourceType_ID = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
// Get Resource Types
@ -289,10 +295,12 @@ public class InfoSchedule extends Window implements EventListener<Event>
"SELECT S_ResourceType_ID, Name FROM S_ResourceType WHERE IsActive='Y' ORDER BY 2",
"S_ResourceType", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair defaultValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -300,13 +308,17 @@ public class InfoSchedule extends Window implements EventListener<Event>
defaultValue = pp;
fieldResourceType.appendItem(pp.getName(), pp.getKey());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (defaultValue != null) {
int cnt = fieldResourceType.getItemCount();
for(int i = 0; i < cnt; i++) {
@ -340,11 +352,13 @@ public class InfoSchedule extends Window implements EventListener<Event>
m_loading = true;
fieldResource.getChildren().clear();
String sql = "SELECT S_Resource_ID, Name FROM S_Resource WHERE S_ResourceType_ID=? ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, S_ResourceType_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -352,13 +366,17 @@ public class InfoSchedule extends Window implements EventListener<Event>
defaultValue = pp;
fieldResource.appendItem(pp.getName(), pp.getKey());
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
if (defaultValue != null) {
int cnt = fieldResource.getItemCount();
for(int i = 0; i < cnt; i++) {

View File

@ -510,12 +510,14 @@ public final class WAccountDialog extends Window
{
log.fine("C_ValidCombination_ID=" + C_ValidCombination_ID);
String sql = "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_ValidCombination_ID);
pstmt.setInt(2, C_AcctSchema_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
if (f_Alias != null)
@ -540,13 +542,17 @@ public final class WAccountDialog extends Window
//
f_Description.setValue (rs.getString("Description"));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadInfo
/**
@ -909,25 +915,31 @@ public final class WAccountDialog extends Window
log.fine("Check = " + sql.toString());
int IDvalue = 0;
String Alias = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_AD_Client_ID);
pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
IDvalue = rs.getInt(1);
Alias = rs.getString(2);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
IDvalue = 0;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("ID=" + IDvalue + ", Alias=" + Alias);
if (Alias == null)

View File

@ -310,10 +310,12 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
+ "FROM S_Resource r, S_ResourceType rt, C_UOM uom "
+ "WHERE r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID",
"r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
StringBuilder sb = new StringBuilder (rs.getString(2));
@ -325,13 +327,17 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
KeyNamePair value = new KeyNamePair (rs.getInt(4), rs.getString(5).trim());
m_lookup.put(key, value);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
// Convert to Array
KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()];

View File

@ -304,25 +304,28 @@ public class WLocatorDialog extends Window implements EventListener<Event>
String SQL = MRole.getDefault().addAccessSQL(
sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
+ " ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
KeyNamePair key = new KeyNamePair(rs.getInt(1), rs.getString(2));
lstWarehouse.appendItem(key.getName(), 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("Warehouses=" + lstWarehouse.getItemCount());
@ -442,12 +445,13 @@ public class WLocatorDialog extends Window implements EventListener<Event>
String SQL = "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID "
+ "FROM M_Warehouse WHERE M_Warehouse_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
@ -458,13 +462,17 @@ public class WLocatorDialog extends Window implements EventListener<Event>
m_AD_Client_ID = rs.getInt(5);
m_AD_Org_ID = rs.getInt(6);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // getWarehouseInfo
/**

View File

@ -119,33 +119,27 @@ public class WRecordAccessDialog extends Window implements EventListener<Event>
sql = "SELECT * FROM AD_Record_Access "
+ "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Table_ID);
pstmt.setInt(2, m_Record_ID);
pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
finally{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("#" + m_recordAccesss.size());
setLine(0, false);
} // dynInit

View File

@ -238,33 +238,27 @@ public class WRecordInfo extends Window implements EventListener<Event>
+ "WHERE AD_Table_ID=? AND Record_ID=? "
+ "ORDER BY Updated DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, dse.AD_Table_ID);
pstmt.setInt (2, Record_ID);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3),
rs.getString(4), rs.getString(5));
}
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

@ -497,13 +497,15 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
+ "WHERE c.AD_Table_ID=? AND c.IsKey='Y'"
+ " AND et.AD_Language=? "
+ "ORDER BY 3";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());
if (trl)
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String tableName = rs.getString(2);
@ -513,13 +515,18 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
name += "/" + poName;
comboDrill.appendItem(name, tableName);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (comboDrill.getItemCount() == 1)
{
labelDrill.setVisible(false);
@ -551,11 +558,13 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
+ "ORDER BY Name",
"AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_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();
while (rs.next())
{
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -567,13 +576,17 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
comboReport.setSelectedItem(li);
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// IDEMPIERE-297 - Check for Table Access and Window Access for New Report
if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false)
&& MRole.getDefault().getWindowAccess(WINDOW_PRINTFORMAT))
@ -1023,25 +1036,30 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab"))
sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?"
+ " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Tab_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
if (rs.next())
{
title = rs.getString(1);
tableName = rs.getString(2);
}
//
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
GridField[] findFields = null;
if (tableName != null)

View File

@ -72,11 +72,13 @@ public class Charge
+ " AND IsSummary='N'"
+ " AND C_Element_ID=? "
+ "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_Element_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(4);
@ -88,13 +90,17 @@ public class Charge
line.add(new Boolean(isExpenseType)); // 3-Expense
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -110,23 +116,28 @@ public class Charge
String sql = "SELECT C_Element_ID "
+ "FROM C_AcctSchema_Element "
+ "WHERE ElementType='AC' AND C_AcctSchema_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_AcctSchema_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_C_Element_ID = rs.getInt(1);
}
rs.close();
pstmt.close();
}
catch (SQLException exception)
{
log.log(Level.SEVERE, sql, exception);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
public Vector<String> getColumnNames()
@ -165,20 +176,26 @@ public class Charge
String sql = "SELECT C_TaxCategory_ID FROM C_TaxCategory "
+ "WHERE IsDefault='Y' AND AD_Client_ID=?";
m_C_TaxCategory_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
m_C_TaxCategory_ID = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // dynInit
/**************************************************************************

View File

@ -122,9 +122,11 @@ public class FactReconcile {
log.fine("SQL=" + sql.toString());
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql.toString(), null);
int i = 1;
pstmt.setInt(i++, m_AD_Client_ID);
@ -149,7 +151,7 @@ public class FactReconcile {
if(m_DateAcct2!=null)
pstmt.setTimestamp(i++, m_DateAcct2);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>();
@ -170,13 +172,17 @@ public class FactReconcile {
//
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -254,21 +260,27 @@ public class FactReconcile {
+ "WHERE ase.ElementType='AC' AND ase.AD_Client_ID=" + m_AD_Client_ID + ") "
+ "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
vector.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return vector;
}

View File

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

View File

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

View File

@ -112,7 +112,7 @@ public class Merge
+ ") AND c.ColumnSQL IS NULL "
+ "ORDER BY t.LoadSeq DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
@ -121,7 +121,7 @@ public class Merge
pstmt = DB.prepareStatement(sql, Trx.createTrxName());
pstmt.setString(1, ColumnName);
pstmt.setString(2, ColumnName);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
String tName = rs.getString(1);
@ -135,9 +135,6 @@ public class Merge
m_totalCount += count;
}
}
rs.close();
pstmt.close();
pstmt = null;
//
log.config("Success=" + success
+ " - " + ColumnName + " - From=" + from_ID + ",To=" + to_ID);
@ -173,17 +170,13 @@ public class Merge
log.log(Level.SEVERE, ColumnName, ex);
success = false;
}
// Cleanup
try
finally
{
if (pstmt != null)
pstmt.close();
}
catch (Exception ex)
{
}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Cleanup
return success;
} // merge

View File

@ -65,24 +65,30 @@ public class PayPrint {
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
+ "ORDER BY PayDate DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
while (rs.next())
{
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(pp);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -105,11 +111,13 @@ public class PayPrint {
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
+ " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
+ "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_C_BankAccount_ID = rs.getInt(1);
@ -127,13 +135,17 @@ public class PayPrint {
m_PaymentExportClass = null;
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadPaySelectInfo
/**
@ -151,24 +163,30 @@ public class PayPrint {
+ " AND " + info.KeyColumn
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
while (rs.next())
{
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
data.add(pp);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (data.size() == 0)
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
@ -191,21 +209,27 @@ public class PayPrint {
String sql = "SELECT COUNT(*) "
+ "FROM C_PaySelectionCheck "
+ "WHERE C_PaySelection_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
if (rs.next())
noPayments = String.valueOf(rs.getInt(1));
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// DocumentNo
sql = "SELECT CurrentNext "
@ -213,10 +237,10 @@ public class PayPrint {
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_BankAccount_ID);
pstmt.setString(2, PaymentRule);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
//
if (rs.next())
documentNo = new Integer(rs.getInt(1));
@ -226,13 +250,17 @@ public class PayPrint {
+ m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule);
msg = "VPayPrintNoDoc";
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return msg;
} // loadPaymentRuleInfo

View File

@ -92,10 +92,12 @@ public class PaySelect
+ " AND EXISTS (SELECT * FROM C_BankAccountDoc d WHERE d.C_BankAccount_ID=ba.C_BankAccount_ID AND d.IsActive='Y' ) "
+ "ORDER BY 2",
"b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
boolean transfers = false;
@ -104,13 +106,17 @@ public class PaySelect
rs.getBigDecimal(5), transfers);
data.add(bi);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -131,23 +137,28 @@ public class PaySelect
+ " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))"
+ " AND i.IsPaid<>'Y') "
+ "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(pp);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -157,6 +168,8 @@ public class PaySelect
ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();
String sql = null;
/**Document type**/
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = MRole.getDefault().addAccessSQL(
@ -165,22 +178,26 @@ public class PaySelect
KeyNamePair dt = new KeyNamePair(0, "");
data.add(dt);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Client_ID); // Client
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
dt = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(dt);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -256,24 +273,30 @@ public class PaySelect
+ " AND " + info.KeyColumn
+ " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) "
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, bi.C_BankAccount_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
ValueNamePair vp = null;
while (rs.next())
{
vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active
data.add(vp);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}
@ -313,10 +336,12 @@ public class PaySelect
log.finest(sql + " - C_Currency_ID=" + bi.C_Currency_ID + ", C_BPartner_ID=" + C_BPartner_ID + ", C_doctype_id=" + c_doctype_id );
// Get Open Invoices
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
int index = 1;
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setTimestamp(index++, payDate); // DiscountAmt
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
pstmt.setTimestamp(index++, payDate);
@ -332,15 +357,19 @@ public class PaySelect
if (c_doctype_id != 0) //Document type
pstmt.setInt(index++, c_doctype_id );
//
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
miniTable.loadTable(rs);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadTableInfo
/**

View File

@ -173,20 +173,26 @@ public class TrxMaterial {
// Get Parent ID
int parentID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, lineID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
parentID = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
query = MQuery.getEqualQuery(ColumnName, parentID);
log.config("AD_Window_ID=" + AD_Window_ID + " - " + query);
if (parentID == 0)

View File

@ -65,11 +65,13 @@ public abstract class CreateFromPackageShipment extends CreateFrom
sqlStmt.append("FROM M_PACKAGELINES_AVAIL_V ");
sqlStmt.append("WHERE M_InOut_ID = ? ");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sqlStmt.toString(), null);
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
pstmt.setInt(1, M_InOut_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(6);
@ -84,13 +86,17 @@ public abstract class CreateFromPackageShipment extends CreateFrom
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sqlStmt.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}

View File

@ -86,12 +86,14 @@ public abstract class CreateFromRMA extends CreateFrom {
sqlStmt.append("WHERE M_InOut_ID=? ");
sqlStmt.append("AND iol.M_InOutLine_ID NOT IN (SELECT rmal.M_InOutLine_ID FROM M_RMALine rmal WHERE rmal.M_RMA_ID=?)");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sqlStmt.toString(), null);
pstmt = DB.prepareStatement(sqlStmt.toString(), null);
pstmt.setInt(1, M_InOut_ID);
pstmt.setInt(2, M_RMA_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
Vector<Object> line = new Vector<Object>(7);
@ -111,13 +113,17 @@ public abstract class CreateFromRMA extends CreateFrom {
data.add(line);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sqlStmt.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data;
}

View File

@ -176,23 +176,29 @@ public abstract class PaymentForm implements IPaymentForm {
String SQL = "SELECT C_Currency_ID, ISO_Code FROM C_Currency "
+ "WHERE (IsEMUMember='Y' AND EMUEntryDate<SysDate) OR IsEuro='Y' "
+ "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int id = rs.getInt(1);
String name = rs.getString(2);
s_Currencies.put(new Integer(id), new KeyNamePair(id, name));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, SQL, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadCurrencies
@Override
@ -211,20 +217,27 @@ public abstract class PaymentForm implements IPaymentForm {
int retValue = 0;
String sql = "SELECT C_Invoice_ID FROM C_Invoice WHERE C_Order_ID=? "
+ "ORDER BY C_Invoice_ID DESC"; // last invoice
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Order_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
} // getInvoiceID

View File

@ -114,10 +114,12 @@ public abstract class PaymentFormCash extends PaymentForm {
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'",
"ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int key = rs.getInt(1);
@ -129,13 +131,17 @@ public abstract class PaymentFormCash extends PaymentForm {
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}
@ -151,10 +157,12 @@ public abstract class PaymentFormCash extends PaymentForm {
String SQL = MRole.getDefault().addAccessSQL(
"SELECT C_CashBook_ID, Name, AD_Org_ID FROM C_CashBook WHERE IsActive='Y'",
"C_CashBook", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int key = rs.getInt(1);
@ -166,13 +174,17 @@ public abstract class PaymentFormCash extends PaymentForm {
if (selectedCashBook == null && key == m_AD_Org_ID) // Default Org
selectedCashBook = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException epc)
{
log.log(Level.SEVERE, SQL, epc);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (selectedCashBook != null)
{

View File

@ -90,10 +90,12 @@ public abstract class PaymentFormCheck extends PaymentForm {
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'",
"ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int key = rs.getInt(1);
@ -105,13 +107,17 @@ public abstract class PaymentFormCheck extends PaymentForm {
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}

View File

@ -82,11 +82,13 @@ public abstract class PaymentFormDirect extends PaymentForm {
+ " LEFT OUTER JOIN C_Bank b ON (a.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE C_BPartner_ID=?"
+ "AND a.IsActive='Y' AND a.IsACH='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
while (rs.next())
{
int key = rs.getInt(1);
@ -94,13 +96,17 @@ public abstract class PaymentFormDirect extends PaymentForm {
KeyNamePair pp = new KeyNamePair(key, name);
list.add(pp);
}
rs.close();
pstmt.close();
}
catch (SQLException eac)
{
log.log(Level.SEVERE, SQL, eac);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}

View File

@ -55,10 +55,12 @@ public abstract class PaymentFormOnCredit extends PaymentForm {
String SQL = MRole.getDefault().addAccessSQL(
"SELECT C_PaymentTerm_ID, Name FROM C_PaymentTerm WHERE IsActive='Y' ORDER BY Name",
"C_PaymentTerm", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery();
pstmt = DB.prepareStatement(SQL, null);
rs = pstmt.executeQuery();
while (rs.next())
{
int key = rs.getInt(1);
@ -68,13 +70,17 @@ public abstract class PaymentFormOnCredit extends PaymentForm {
if (pp.getKey() == m_C_PaymentTerm_ID)
selectedPaymentTerm = pp;
}
rs.close();
pstmt.close();
}
catch (SQLException ept)
{
log.log(Level.SEVERE, SQL, ept);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list;
}

View File

@ -210,8 +210,6 @@ public class ReportInfo
hasError = true;
log.saveError("Error", "The Report File not exists");
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
@ -231,12 +229,9 @@ public class ReportInfo
}
finally
{
try
{
if(rs != null) rs.close();
if(pstmt != null) pstmt.close();
}
catch(Exception ex){}
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.info("Get ReportDefinition-" + this.toString());
}