Merge 04277f8ad9d3

This commit is contained in:
Heng Sin Low 2013-02-18 12:09:05 +08:00
commit 6a8ded433e
64 changed files with 955 additions and 494 deletions

View File

@ -0,0 +1,35 @@
-- Feb 14, 2013 9:38:24 AM COT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Element SET Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)',Updated=TO_DATE('2013-02-14 09:38:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Column SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Process_Para SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL, AD_Element_ID=200188 WHERE UPPER(ColumnName)='M_RESERVELOCATOR_ID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Process_Para SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188 AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_InfoColumn SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188 AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Field SET Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=200188) AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_PrintFormatItem pi SET PrintName='Reserve Locator', Name='Reservation Locator' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=200188)
;
SELECT register_migration_script('201302140947_IDEMPIERE-385.sql') FROM dual;

View File

@ -0,0 +1,18 @@
-- Feb 15, 2013 12:19:22 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,EntityType,Name,Description,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Client_ID,IsActive,AD_Org_ID) VALUES ('EXISTS (SELECT * FROM C_BPartner bp WHERE AD_User.C_BPartner_ID=bp.C_BPartner_ID AND bp.IsSalesRep=''Y'')',200025,'D','AD_User - SalesRep','Sales Reps','S','acb880d9-586d-4139-8bfd-4f275cda2e8a',100,100,TO_DATE('2013-02-15 12:19:21','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-02-15 12:19:21','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Feb 15, 2013 12:19:43 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
UPDATE AD_Column SET AD_Reference_Value_ID=110, AD_Val_Rule_ID=200025,Updated=TO_DATE('2013-02-15 12:19:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2186
;
-- Feb 15, 2013 12:20:22 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
UPDATE AD_Column SET AD_Reference_Value_ID=110, AD_Val_Rule_ID=200025,Updated=TO_DATE('2013-02-15 12:20:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4431
;
SELECT register_migration_script('201302151223_IDEMPIERE-635.sql') FROM dual
;

View File

@ -0,0 +1,35 @@
-- Feb 14, 2013 9:38:24 AM COT
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Element SET Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)',Updated=TO_TIMESTAMP('2013-02-14 09:38:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Column SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Process_Para SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL, AD_Element_ID=200188 WHERE UPPER(ColumnName)='M_RESERVELOCATOR_ID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Process_Para SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188 AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_InfoColumn SET ColumnName='M_ReserveLocator_ID', Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Element_ID=200188 AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_Field SET Name='Reservation Locator', Description='Reservation Locator (just for reporting purposes)', Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=200188) AND IsCentrallyMaintained='Y'
;
-- Feb 14, 2013 9:38:24 AM COT
UPDATE AD_PrintFormatItem SET PrintName='Reserve Locator', Name='Reservation Locator' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=200188)
;
SELECT register_migration_script('201302140947_IDEMPIERE-385.sql') FROM dual;

View File

@ -0,0 +1,18 @@
-- Feb 15, 2013 12:19:22 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
INSERT INTO AD_Val_Rule (Code,AD_Val_Rule_ID,EntityType,Name,Description,Type,AD_Val_Rule_UU,CreatedBy,UpdatedBy,Updated,Created,AD_Client_ID,IsActive,AD_Org_ID) VALUES ('EXISTS (SELECT * FROM C_BPartner bp WHERE AD_User.C_BPartner_ID=bp.C_BPartner_ID AND bp.IsSalesRep=''Y'')',200025,'D','AD_User - SalesRep','Sales Reps','S','acb880d9-586d-4139-8bfd-4f275cda2e8a',100,100,TO_TIMESTAMP('2013-02-15 12:19:21','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-02-15 12:19:21','YYYY-MM-DD HH24:MI:SS'),0,'Y',0)
;
-- Feb 15, 2013 12:19:43 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
UPDATE AD_Column SET AD_Reference_Value_ID=110, AD_Val_Rule_ID=200025,Updated=TO_TIMESTAMP('2013-02-15 12:19:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=2186
;
-- Feb 15, 2013 12:20:22 PM COT
-- IDEMPIERE-635 Reference validation behaving different than Dynamic Validation
UPDATE AD_Column SET AD_Reference_Value_ID=110, AD_Val_Rule_ID=200025,Updated=TO_TIMESTAMP('2013-02-15 12:20:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=4431
;
SELECT register_migration_script('201302151223_IDEMPIERE-635.sql') FROM dual
;

View File

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

View File

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

View File

@ -83,36 +83,40 @@ public class Doc_Production extends Doc
String sqlPL = "SELECT * FROM M_ProductionLine pl " String sqlPL = "SELECT * FROM M_ProductionLine pl "
+ "WHERE pl.M_Production_ID=? " + "WHERE pl.M_Production_ID=? "
+ "ORDER BY pl.Line"; + "ORDER BY pl.Line";
PreparedStatement pstmtPL = null;
ResultSet rsPL = null;
try try
{ {
pstmtPL = DB.prepareStatement(sqlPL, getTrxName());
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL, getTrxName()); pstmtPL.setInt(1,get_ID());
pstmtPL.setInt(1,get_ID()); rsPL = pstmtPL.executeQuery();
ResultSet rsPL = pstmtPL.executeQuery(); while (rsPL.next())
while (rsPL.next()) {
{ X_M_ProductionLine line = new X_M_ProductionLine(getCtx(), rsPL, getTrxName());
X_M_ProductionLine line = new X_M_ProductionLine(getCtx(), rsPL, getTrxName()); if (line.getMovementQty().signum() == 0)
if (line.getMovementQty().signum() == 0)
{
log.info("LineQty=0 - " + line);
continue;
}
DocLine docLine = new DocLine (line, this);
docLine.setQty (line.getMovementQty(), false);
// Identify finished BOM Product
docLine.setProductionBOM(line.getM_Product_ID() == prod.getM_Product_ID());
//
log.fine(docLine.toString());
list.add (docLine);
}
rsPL.close();
pstmtPL.close();
}
catch (Exception ee)
{ {
log.log(Level.SEVERE, sqlPL, ee); log.info("LineQty=0 - " + line);
continue;
} }
DocLine docLine = new DocLine (line, this);
docLine.setQty (line.getMovementQty(), false);
// Identify finished BOM Product
docLine.setProductionBOM(line.getM_Product_ID() == prod.getM_Product_ID());
//
log.fine(docLine.toString());
list.add (docLine);
}
}
catch (Exception ee)
{
log.log(Level.SEVERE, sqlPL, ee);
}
finally
{
DB.close(rsPL, pstmtPL);
rsPL = null;
pstmtPL = null;
}
DocLine[] dl = new DocLine[list.size()]; DocLine[] dl = new DocLine[list.size()];
list.toArray(dl); list.toArray(dl);

View File

@ -353,11 +353,13 @@ public class CreateAdempiere
StringBuilder sb = new StringBuilder("CREATE TABLE "); StringBuilder sb = new StringBuilder("CREATE TABLE ");
sb.append(tableName).append(" ("); sb.append(tableName).append(" (");
ResultSet sourceColumns = null;
ResultSet sourcePK = null;
try try
{ {
// Columns // Columns
boolean first = true; boolean first = true;
ResultSet sourceColumns = md.getColumns(catalog, schema, table, null); sourceColumns = md.getColumns(catalog, schema, table, null);
while (sourceColumns.next()) while (sourceColumns.next())
{ {
sb.append(first ? "" : ", "); sb.append(first ? "" : ", ");
@ -431,10 +433,9 @@ public class CreateAdempiere
} // for all columns } // for all columns
sourceColumns.close();
// Primary Key // 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 // 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; first = true;
boolean hasPK = false; boolean hasPK = false;
@ -451,7 +452,6 @@ public class CreateAdempiere
} }
if (hasPK) // close constraint if (hasPK) // close constraint
sb.append(")"); // USING INDEX TABLESPACE INDX sb.append(")"); // USING INDEX TABLESPACE INDX
sourcePK.close();
// //
sb.append(")"); // close create table sb.append(")"); // close create table
} }
@ -460,6 +460,13 @@ public class CreateAdempiere
log.log(Level.SEVERE, "createTable", ex); log.log(Level.SEVERE, "createTable", ex);
return false; return false;
} }
finally
{
DB.close(sourceColumns);
DB.close(sourcePK);
sourceColumns = null;
sourcePK = null;
}
// Execute Create Table // Execute Create Table
if (!executeCommands(new String[]{sb.toString()}, m_conn, false, true)) 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) " + " 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 + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID.intValue()); pstmt.setInt(1, C_BPartner_ID.intValue());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
if (rs.next()) if (rs.next())
{ {
@ -125,14 +127,18 @@ public class CalloutUser extends CalloutEngine
else else
mTab.setValue("AD_User_ID", new Integer(contID)); mTab.setValue("AD_User_ID", new Integer(contID));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage(); return e.getLocalizedMessage();
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return ""; return "";
} // bPartner } // bPartner
@ -160,20 +166,26 @@ public class CalloutUser extends CalloutEngine
// //
String retValue = value; String retValue = value;
String SQL = "SELECT FRIE_Name(?) FROM DUAL"; String SQL = "SELECT FRIE_Name(?) FROM DUAL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, value); pstmt.setString(1, value);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
retValue = rs.getString(1); retValue = rs.getString(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue; return retValue;
} // Frie_Name } // Frie_Name
@ -191,20 +203,26 @@ public class CalloutUser extends CalloutEngine
// //
String retValue = value; String retValue = value;
String SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL"; String SQL = "SELECT FRIE_Value(FRIE_Name(?)) FROM DUAL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setString(1, value); pstmt.setString(1, value);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
retValue = rs.getString(1); retValue = rs.getString(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
return retValue; return retValue;
} // Frie_Value } // Frie_Value

View File

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

View File

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

View File

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

View File

@ -233,23 +233,29 @@ public class ProcessParameter extends CDialog
// Create Fields // Create Fields
boolean hasFields = false; boolean hasFields = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_processInfo.getAD_Process_ID()); pstmt.setInt(1, m_processInfo.getAD_Process_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
hasFields = true; hasFields = true;
createField (rs); createField (rs);
} }
rs.close();
pstmt.close();
} }
catch(SQLException e) catch(SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// both vectors the same? // both vectors the same?
if (m_mFields.size() != m_mFields2.size() 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=? " + "WHERE AD_Table_ID=? AND Record_ID=? "
+ "ORDER BY Updated DESC"; + "ORDER BY Updated DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, dse.AD_Table_ID); pstmt.setInt (1, dse.AD_Table_ID);
pstmt.setInt (2, Record_ID); pstmt.setInt (2, Record_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3), addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3),
rs.getString(4), rs.getString(5)); rs.getString(4), rs.getString(5));
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }

View File

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

View File

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

View File

@ -123,31 +123,25 @@ public class RecordAccessDialog extends CDialog
sql = "SELECT * FROM AD_Record_Access " sql = "SELECT * FROM AD_Record_Access "
+ "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?"; + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Table_ID); pstmt.setInt(1, m_AD_Table_ID);
pstmt.setInt(2, m_Record_ID); pstmt.setInt(2, m_Record_ID);
pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx())); pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null)); m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
log.fine("#" + m_recordAccesss.size()); 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 " String sql = "SELECT C_Currency_ID, ISO_Code FROM C_Currency "
+ "WHERE IsActive='Y' ORDER BY 2"; + "WHERE IsActive='Y' ORDER BY 2";
KeyNamePair defaultValue = null; KeyNamePair defaultValue = null;
Statement stmt = null;
ResultSet rs = null;
try try
{ {
Statement stmt = DB.createStatement(); stmt = DB.createStatement();
ResultSet rs = stmt.executeQuery(sql); rs = stmt.executeQuery(sql);
while (rs.next()) while (rs.next())
{ {
int id = rs.getInt("C_Currency_ID"); int id = rs.getInt("C_Currency_ID");
@ -591,13 +593,17 @@ public final class Calculator extends CDialog
if (id == C_Currency_ID) if (id == C_Currency_ID)
defaultValue = p; defaultValue = p;
} }
rs.close();
stmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "Calculator.loadCurrency", e); log.log(Level.SEVERE, "Calculator.loadCurrency", e);
} }
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
// Set Defaults // Set Defaults
if (defaultValue != null) if (defaultValue != null)

View File

@ -373,35 +373,29 @@ public final class VAccount extends JComponent
// //
int C_ValidCombination_ID = 0; int C_ValidCombination_ID = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_AcctSchema_ID); pstmt.setInt(1, C_AcctSchema_ID);
pstmt.setString(2, text.toUpperCase()); pstmt.setString(2, text.toUpperCase());
pstmt.setString(3, text.toUpperCase()); pstmt.setString(3, text.toUpperCase());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
C_ValidCombination_ID = rs.getInt(1); C_ValidCombination_ID = rs.getInt(1);
if (rs.next()) // only one if (rs.next()) // only one
C_ValidCombination_ID = 0; C_ValidCombination_ID = 0;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }
// We have a Value // We have a Value

View File

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

View File

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

View File

@ -348,10 +348,12 @@ public class VAssignmentDialog extends CDialog
+ "FROM S_Resource r, S_ResourceType rt, C_UOM uom " + "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", + "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); "r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
StringBuilder sb = new StringBuilder (rs.getString(2)); 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()); KeyNamePair value = new KeyNamePair (rs.getInt(4), rs.getString(5).trim());
m_lookup.put(key, value); m_lookup.put(key, value);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} }
// Convert to Array // Convert to Array
KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()]; 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" + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID"
+ " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'" + " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"
+ " AND l.AD_Reference_ID=?"; + " AND l.AD_Reference_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, AD_Reference_ID); pstmt.setInt(1, AD_Reference_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
String value = rs.getString(1); String value = rs.getString(1);
String name = rs.getString(2); String name = rs.getString(2);
m_values.put(value, name); m_values.put(value, name);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // readReference } // readReference
/** /**

View File

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

View File

@ -463,6 +463,7 @@ public class VLocator extends JComponent
// //
int M_Locator_ID = 0; int M_Locator_ID = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(finalSql, null); 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);
pstmt.setInt(index++, only_Product_ID); pstmt.setInt(index++, only_Product_ID);
} }
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
M_Locator_ID = rs.getInt(1); M_Locator_ID = rs.getInt(1);
if (rs.next()) if (rs.next())
M_Locator_ID = 0; // more than one M_Locator_ID = 0; // more than one
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, finalSql, ex); log.log(Level.SEVERE, finalSql, ex);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close(); rs = null;
pstmt = null;
} }
catch (SQLException ex1)
{
}
pstmt = null;
if (M_Locator_ID == 0) if (M_Locator_ID == 0)
return false; 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 " String SQL = "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID "
+ "FROM M_Warehouse WHERE M_Warehouse_ID=?"; + "FROM M_Warehouse WHERE M_Warehouse_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, M_Warehouse_ID); pstmt.setInt(1, M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
m_M_Warehouse_ID = rs.getInt(1); 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_Client_ID = rs.getInt(5);
m_AD_Org_ID = rs.getInt(6); m_AD_Org_ID = rs.getInt(6);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // getWarehouseInfo } // getWarehouseInfo
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -155,9 +155,6 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
if (rs.next()) // only one if (rs.next()) // only one
C_ValidCombination_ID = 0; C_ValidCombination_ID = 0;
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) 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 r.S_ResourceType_ID=rt.S_ResourceType_ID"
+ " and rt.C_UOM_ID=uom.C_UOM_ID", null); + " and rt.C_UOM_ID=uom.C_UOM_ID", null);
// //
ResultSet rs = null;
try try
{ {
m_pstmt.setInt(1, S_ResourceAssignment_ID); m_pstmt.setInt(1, S_ResourceAssignment_ID);
ResultSet rs = m_pstmt.executeQuery(); rs = m_pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
StringBuilder sb = new StringBuilder(rs.getString(1)); StringBuilder sb = new StringBuilder(rs.getString(1));
@ -127,12 +128,15 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
} }
else else
getComponent().setText("<" + S_ResourceAssignment_ID + ">"); getComponent().setText("<" + S_ResourceAssignment_ID + ">");
rs.close();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "", 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; int M_Locator_ID = 0;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(finalSql, null); pstmt = DB.prepareStatement(finalSql, null);
@ -372,7 +372,7 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
pstmt.setInt(index++, only_Product_ID); pstmt.setInt(index++, only_Product_ID);
} }
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
@ -381,25 +381,17 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
if (rs.next()) if (rs.next())
M_Locator_ID = 0; // more than one M_Locator_ID = 0; // more than one
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException ex) catch (SQLException ex)
{ {
log.log(Level.SEVERE, finalSql, ex); log.log(Level.SEVERE, finalSql, ex);
} }
finally
try
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close(); rs = null;
pstmt = null;
} }
catch (SQLException ex1)
{
}
pstmt = null;
if (M_Locator_ID == 0) if (M_Locator_ID == 0)
return false; return false;

View File

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

View File

@ -23,6 +23,7 @@ import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Rows;
import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.editor.WebEditorFactory; import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.ValueChangeListener;
@ -610,6 +611,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
if (mField.getDisplayType() == DisplayType.PAttribute) if (mField.getDisplayType() == DisplayType.PAttribute)
{ {
editor = new WInfoPAttributeEditor(infoContext, p_WindowNo, mField); editor = new WInfoPAttributeEditor(infoContext, p_WindowNo, mField);
editor.setReadWrite(true);
} }
else else
{ {
@ -798,6 +800,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
if (evt != null && evt.getSource() instanceof WEditor) if (evt != null && evt.getSource() instanceof WEditor)
{ {
WEditor editor = (WEditor)evt.getSource(); WEditor editor = (WEditor)evt.getSource();
boolean asiChanged = false;
if (evt.getNewValue() == null) { if (evt.getNewValue() == null) {
Env.setContext(infoContext, p_WindowNo, editor.getColumnName(), ""); Env.setContext(infoContext, p_WindowNo, editor.getColumnName(), "");
Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, editor.getColumnName(), ""); Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, editor.getColumnName(), "");
@ -811,11 +814,16 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
Env.setContext(infoContext, p_WindowNo, editor.getColumnName(), evt.getNewValue().toString()); Env.setContext(infoContext, p_WindowNo, editor.getColumnName(), evt.getNewValue().toString());
Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, editor.getColumnName(), evt.getNewValue().toString()); Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, editor.getColumnName(), evt.getNewValue().toString());
} }
// if attribute set changed (from any value to any value) clear the attribute set instance m_pAttributeWhere
if (editor instanceof WTableDirEditor && editor.getColumnName().equals("M_AttributeSet_ID"))
asiChanged = true;
for(WEditor otherEditor : editors) for(WEditor otherEditor : editors)
{ {
if (otherEditor == editor) if (otherEditor == editor)
continue; continue;
if (asiChanged && otherEditor instanceof WInfoPAttributeEditor)
((WInfoPAttributeEditor)otherEditor).clearWhereClause();
otherEditor.dynamicDisplay(); otherEditor.dynamicDisplay();
} }

View File

@ -109,6 +109,10 @@ public class WInfoPAttributeEditor extends WEditor implements IWhereClauseEditor
return m_pAttributeWhere; return m_pAttributeWhere;
} }
public void clearWhereClause() {
m_pAttributeWhere = null;
}
/** /**
* Query per Product Attribute. * Query per Product Attribute.
* <code> * <code>
@ -138,7 +142,7 @@ public class WInfoPAttributeEditor extends WEditor implements IWhereClauseEditor
@Override @Override
public void dynamicDisplay() { public void dynamicDisplay() {
int attributeSetId = Env.getContextAsInt(ctx, windowNo, Env.TAB_INFO, "M_AttributeSet_ID"); // int attributeSetId = Env.getContextAsInt(ctx, windowNo, Env.TAB_INFO, "M_AttributeSet_ID");
setReadWrite(attributeSetId > 0); // setReadWrite(attributeSetId > 0);
} }
} }

View File

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

View File

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

View File

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

View File

@ -268,20 +268,26 @@ public class InfoSchedule extends Window implements EventListener<Event>
if (m_mAssignment.getS_Resource_ID() != 0) if (m_mAssignment.getS_Resource_ID() != 0)
{ {
String sql = "SELECT S_ResourceType_ID FROM S_Resource WHERE S_Resource_ID=?"; String sql = "SELECT S_ResourceType_ID FROM S_Resource WHERE S_Resource_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_mAssignment.getS_Resource_ID()); pstmt.setInt(1, m_mAssignment.getS_Resource_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
S_ResourceType_ID = rs.getInt(1); S_ResourceType_ID = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} }
// Get Resource Types // 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", "SELECT S_ResourceType_ID, Name FROM S_ResourceType WHERE IsActive='Y' ORDER BY 2",
"S_ResourceType", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); "S_ResourceType", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair defaultValue = null; KeyNamePair defaultValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -300,13 +308,17 @@ public class InfoSchedule extends Window implements EventListener<Event>
defaultValue = pp; defaultValue = pp;
fieldResourceType.appendItem(pp.getName(), pp.getKey()); fieldResourceType.appendItem(pp.getName(), pp.getKey());
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (defaultValue != null) { if (defaultValue != null) {
int cnt = fieldResourceType.getItemCount(); int cnt = fieldResourceType.getItemCount();
for(int i = 0; i < cnt; i++) { for(int i = 0; i < cnt; i++) {
@ -340,11 +352,13 @@ public class InfoSchedule extends Window implements EventListener<Event>
m_loading = true; m_loading = true;
fieldResource.getChildren().clear(); fieldResource.getChildren().clear();
String sql = "SELECT S_Resource_ID, Name FROM S_Resource WHERE S_ResourceType_ID=? ORDER BY 2"; String sql = "SELECT S_Resource_ID, Name FROM S_Resource WHERE S_ResourceType_ID=? ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, S_ResourceType_ID); pstmt.setInt(1, S_ResourceType_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
@ -352,13 +366,17 @@ public class InfoSchedule extends Window implements EventListener<Event>
defaultValue = pp; defaultValue = pp;
fieldResource.appendItem(pp.getName(), pp.getKey()); fieldResource.appendItem(pp.getName(), pp.getKey());
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs,pstmt);
rs = null;
pstmt = null;
}
if (defaultValue != null) { if (defaultValue != null) {
int cnt = fieldResource.getItemCount(); int cnt = fieldResource.getItemCount();
for(int i = 0; i < cnt; i++) { 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); log.fine("C_ValidCombination_ID=" + C_ValidCombination_ID);
String sql = "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?"; String sql = "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_ValidCombination_ID); pstmt.setInt(1, C_ValidCombination_ID);
pstmt.setInt(2, C_AcctSchema_ID); pstmt.setInt(2, C_AcctSchema_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
if (f_Alias != null) if (f_Alias != null)
@ -540,13 +542,17 @@ public final class WAccountDialog extends Window
// //
f_Description.setValue (rs.getString("Description")); f_Description.setValue (rs.getString("Description"));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadInfo } // loadInfo
/** /**
@ -909,25 +915,31 @@ public final class WAccountDialog extends Window
log.fine("Check = " + sql.toString()); log.fine("Check = " + sql.toString());
int IDvalue = 0; int IDvalue = 0;
String Alias = null; String Alias = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, m_AD_Client_ID); pstmt.setInt(1, m_AD_Client_ID);
pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID()); pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
IDvalue = rs.getInt(1); IDvalue = rs.getInt(1);
Alias = rs.getString(2); Alias = rs.getString(2);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql.toString(), e); log.log(Level.SEVERE, sql.toString(), e);
IDvalue = 0; IDvalue = 0;
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("ID=" + IDvalue + ", Alias=" + Alias); log.fine("ID=" + IDvalue + ", Alias=" + Alias);
if (Alias == null) 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 " + "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", + "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); "r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
StringBuilder sb = new StringBuilder (rs.getString(2)); 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()); KeyNamePair value = new KeyNamePair (rs.getInt(4), rs.getString(5).trim());
m_lookup.put(key, value); m_lookup.put(key, value);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} }
// Convert to Array // Convert to Array
KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()]; 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( String SQL = MRole.getDefault().addAccessSQL(
sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
+ " ORDER BY 2"; + " ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
KeyNamePair key = new KeyNamePair(rs.getInt(1), rs.getString(2)); KeyNamePair key = new KeyNamePair(rs.getInt(1), rs.getString(2));
lstWarehouse.appendItem(key.getName(), key); lstWarehouse.appendItem(key.getName(), key);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("Warehouses=" + lstWarehouse.getItemCount()); 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 " String SQL = "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID "
+ "FROM M_Warehouse WHERE M_Warehouse_ID=?"; + "FROM M_Warehouse WHERE M_Warehouse_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, M_Warehouse_ID); pstmt.setInt(1, M_Warehouse_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
@ -458,13 +462,17 @@ public class WLocatorDialog extends Window implements EventListener<Event>
m_AD_Client_ID = rs.getInt(5); m_AD_Client_ID = rs.getInt(5);
m_AD_Org_ID = rs.getInt(6); m_AD_Org_ID = rs.getInt(6);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // getWarehouseInfo } // getWarehouseInfo
/** /**

View File

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

View File

@ -238,33 +238,27 @@ public class WRecordInfo extends Window implements EventListener<Event>
+ "WHERE AD_Table_ID=? AND Record_ID=? " + "WHERE AD_Table_ID=? AND Record_ID=? "
+ "ORDER BY Updated DESC"; + "ORDER BY Updated DESC";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, dse.AD_Table_ID); pstmt.setInt (1, dse.AD_Table_ID);
pstmt.setInt (2, Record_ID); pstmt.setInt (2, Record_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3), addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3),
rs.getString(4), rs.getString(5)); rs.getString(4), rs.getString(5));
} }
rs.close ();
pstmt.close ();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(rs, pstmt);
rs = null;
pstmt = null; pstmt = null;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -65,24 +65,30 @@ public class PayPrint {
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection " String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'" + "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
+ "ORDER BY PayDate DESC"; + "ORDER BY PayDate DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID); pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
while (rs.next()) while (rs.next())
{ {
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(pp); data.add(pp);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; 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_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) " + " 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'"; + "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID); pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
m_C_BankAccount_ID = rs.getInt(1); m_C_BankAccount_ID = rs.getInt(1);
@ -127,13 +135,17 @@ public class PayPrint {
m_PaymentExportClass = null; m_PaymentExportClass = null;
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID); log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadPaySelectInfo } // loadPaySelectInfo
/** /**
@ -151,24 +163,30 @@ public class PayPrint {
+ " AND " + info.KeyColumn + " AND " + info.KeyColumn
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) " + " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
+ info.Query.substring(info.Query.indexOf(" ORDER BY")); + info.Query.substring(info.Query.indexOf(" ORDER BY"));
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID); pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
while (rs.next()) while (rs.next())
{ {
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3)); ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
data.add(pp); data.add(pp);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (data.size() == 0) if (data.size() == 0)
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql); log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
@ -191,21 +209,27 @@ public class PayPrint {
String sql = "SELECT COUNT(*) " String sql = "SELECT COUNT(*) "
+ "FROM C_PaySelectionCheck " + "FROM C_PaySelectionCheck "
+ "WHERE C_PaySelection_ID=?"; + "WHERE C_PaySelection_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID); pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
if (rs.next()) if (rs.next())
noPayments = String.valueOf(rs.getInt(1)); noPayments = String.valueOf(rs.getInt(1));
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// DocumentNo // DocumentNo
sql = "SELECT CurrentNext " sql = "SELECT CurrentNext "
@ -213,10 +237,10 @@ public class PayPrint {
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'"; + "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_BankAccount_ID); pstmt.setInt(1, m_C_BankAccount_ID);
pstmt.setString(2, PaymentRule); pstmt.setString(2, PaymentRule);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
// //
if (rs.next()) if (rs.next())
documentNo = new Integer(rs.getInt(1)); documentNo = new Integer(rs.getInt(1));
@ -226,13 +250,17 @@ public class PayPrint {
+ m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule); + m_C_BankAccount_ID + " AND PaymentRule=" + PaymentRule);
msg = "VPayPrintNoDoc"; msg = "VPayPrintNoDoc";
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return msg; return msg;
} // loadPaymentRuleInfo } // 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' ) " + " AND EXISTS (SELECT * FROM C_BankAccountDoc d WHERE d.C_BankAccount_ID=ba.C_BankAccount_ID AND d.IsActive='Y' ) "
+ "ORDER BY 2", + "ORDER BY 2",
"b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW); "b", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RW);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
boolean transfers = false; boolean transfers = false;
@ -104,13 +106,17 @@ public class PaySelect
rs.getBigDecimal(5), transfers); rs.getBigDecimal(5), transfers);
data.add(bi); data.add(bi);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; return data;
} }
@ -131,23 +137,28 @@ public class PaySelect
+ " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))" + " AND (i.IsSOTrx='N' OR (i.IsSOTrx='Y' AND i.PaymentRule='D'))"
+ " AND i.IsPaid<>'Y') " + " AND i.IsPaid<>'Y') "
+ "ORDER BY 2"; + "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(pp); data.add(pp);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; return data;
} }
@ -157,6 +168,8 @@ public class PaySelect
ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>(); ArrayList<KeyNamePair> data = new ArrayList<KeyNamePair>();
String sql = null; String sql = null;
/**Document type**/ /**Document type**/
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
sql = MRole.getDefault().addAccessSQL( sql = MRole.getDefault().addAccessSQL(
@ -165,22 +178,26 @@ public class PaySelect
KeyNamePair dt = new KeyNamePair(0, ""); KeyNamePair dt = new KeyNamePair(0, "");
data.add(dt); data.add(dt);
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Client_ID); // Client pstmt.setInt(1, m_AD_Client_ID); // Client
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
dt = new KeyNamePair(rs.getInt(1), rs.getString(2)); dt = new KeyNamePair(rs.getInt(1), rs.getString(2));
data.add(dt); data.add(dt);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; return data;
} }
@ -256,24 +273,30 @@ public class PaySelect
+ " AND " + info.KeyColumn + " AND " + info.KeyColumn
+ " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) " + " IN (SELECT PaymentRule FROM C_BankAccountDoc WHERE C_BankAccount_ID=?) "
+ info.Query.substring(info.Query.indexOf(" ORDER BY")); + info.Query.substring(info.Query.indexOf(" ORDER BY"));
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, bi.C_BankAccount_ID); pstmt.setInt(1, bi.C_BankAccount_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
ValueNamePair vp = null; ValueNamePair vp = null;
while (rs.next()) while (rs.next())
{ {
vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active vp = new ValueNamePair(rs.getString(2), rs.getString(3)); // returns also not active
data.add(vp); data.add(vp);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; 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 ); 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 // Get Open Invoices
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
int index = 1; int index = 1;
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setTimestamp(index++, payDate); // DiscountAmt pstmt.setTimestamp(index++, payDate); // DiscountAmt
pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt pstmt.setInt(index++, bi.C_Currency_ID); // DueAmt
pstmt.setTimestamp(index++, payDate); pstmt.setTimestamp(index++, payDate);
@ -332,15 +357,19 @@ public class PaySelect
if (c_doctype_id != 0) //Document type if (c_doctype_id != 0) //Document type
pstmt.setInt(index++, c_doctype_id ); pstmt.setInt(index++, c_doctype_id );
// //
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
miniTable.loadTable(rs); miniTable.loadTable(rs);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadTableInfo } // loadTableInfo
/** /**

View File

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

View File

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

View File

@ -86,12 +86,14 @@ public abstract class CreateFromRMA extends CreateFrom {
sqlStmt.append("WHERE M_InOut_ID=? "); 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=?)"); 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 try
{ {
PreparedStatement pstmt = DB.prepareStatement(sqlStmt.toString(), null); pstmt = DB.prepareStatement(sqlStmt.toString(), null);
pstmt.setInt(1, M_InOut_ID); pstmt.setInt(1, M_InOut_ID);
pstmt.setInt(2, M_RMA_ID); pstmt.setInt(2, M_RMA_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
Vector<Object> line = new Vector<Object>(7); Vector<Object> line = new Vector<Object>(7);
@ -111,13 +113,17 @@ public abstract class CreateFromRMA extends CreateFrom {
data.add(line); data.add(line);
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sqlStmt.toString(), e); log.log(Level.SEVERE, sqlStmt.toString(), e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return data; 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 " String SQL = "SELECT C_Currency_ID, ISO_Code FROM C_Currency "
+ "WHERE (IsEMUMember='Y' AND EMUEntryDate<SysDate) OR IsEuro='Y' " + "WHERE (IsEMUMember='Y' AND EMUEntryDate<SysDate) OR IsEuro='Y' "
+ "ORDER BY 2"; + "ORDER BY 2";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int id = rs.getInt(1); int id = rs.getInt(1);
String name = rs.getString(2); String name = rs.getString(2);
s_Currencies.put(new Integer(id), new KeyNamePair(id, name)); s_Currencies.put(new Integer(id), new KeyNamePair(id, name));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, SQL, e); log.log(Level.SEVERE, SQL, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} // loadCurrencies } // loadCurrencies
@Override @Override
@ -211,20 +217,27 @@ public abstract class PaymentForm implements IPaymentForm {
int retValue = 0; int retValue = 0;
String sql = "SELECT C_Invoice_ID FROM C_Invoice WHERE C_Order_ID=? " String sql = "SELECT C_Invoice_ID FROM C_Invoice WHERE C_Order_ID=? "
+ "ORDER BY C_Invoice_ID DESC"; // last invoice + "ORDER BY C_Invoice_ID DESC"; // last invoice
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_Order_ID); pstmt.setInt(1, C_Order_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
retValue = rs.getInt(1); retValue = rs.getInt(1);
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue; return retValue;
} // getInvoiceID } // 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) " + " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'", + "WHERE b.IsActive='Y'",
"ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); "ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int key = rs.getInt(1); int key = rs.getInt(1);
@ -129,13 +131,17 @@ public abstract class PaymentFormCash extends PaymentForm {
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp; selectedBankAccount = pp;
} }
rs.close();
pstmt.close();
} }
catch (SQLException ept) catch (SQLException ept)
{ {
log.log(Level.SEVERE, SQL, ept); log.log(Level.SEVERE, SQL, ept);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list; return list;
} }
@ -151,10 +157,12 @@ public abstract class PaymentFormCash extends PaymentForm {
String SQL = MRole.getDefault().addAccessSQL( String SQL = MRole.getDefault().addAccessSQL(
"SELECT C_CashBook_ID, Name, AD_Org_ID FROM C_CashBook WHERE IsActive='Y'", "SELECT C_CashBook_ID, Name, AD_Org_ID FROM C_CashBook WHERE IsActive='Y'",
"C_CashBook", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); "C_CashBook", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int key = rs.getInt(1); 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 if (selectedCashBook == null && key == m_AD_Org_ID) // Default Org
selectedCashBook = pp; selectedCashBook = pp;
} }
rs.close();
pstmt.close();
} }
catch (SQLException epc) catch (SQLException epc)
{ {
log.log(Level.SEVERE, SQL, epc); log.log(Level.SEVERE, SQL, epc);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
if (selectedCashBook != 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) " + " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'", + "WHERE b.IsActive='Y'",
"ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); "ba", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int key = rs.getInt(1); int key = rs.getInt(1);
@ -105,13 +107,17 @@ public abstract class PaymentFormCheck extends PaymentForm {
if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default if (selectedBankAccount == null && rs.getString(3).equals("Y")) // Default
selectedBankAccount = pp; selectedBankAccount = pp;
} }
rs.close();
pstmt.close();
} }
catch (SQLException ept) catch (SQLException ept)
{ {
log.log(Level.SEVERE, SQL, ept); log.log(Level.SEVERE, SQL, ept);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list; 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) " + " LEFT OUTER JOIN C_Bank b ON (a.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE C_BPartner_ID=?" + "WHERE C_BPartner_ID=?"
+ "AND a.IsActive='Y' AND a.IsACH='Y'"; + "AND a.IsActive='Y' AND a.IsACH='Y'";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(SQL, null); pstmt = DB.prepareStatement(SQL, null);
pstmt.setInt(1, m_C_BPartner_ID); pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
int key = rs.getInt(1); int key = rs.getInt(1);
@ -94,13 +96,17 @@ public abstract class PaymentFormDirect extends PaymentForm {
KeyNamePair pp = new KeyNamePair(key, name); KeyNamePair pp = new KeyNamePair(key, name);
list.add(pp); list.add(pp);
} }
rs.close();
pstmt.close();
} }
catch (SQLException eac) catch (SQLException eac)
{ {
log.log(Level.SEVERE, SQL, eac); log.log(Level.SEVERE, SQL, eac);
} }
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return list; return list;
} }

View File

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

View File

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