BF [ 1874419 ] JDBC Statement not close in a finally block

- changed Query.list method signature as we discussed on tracker's page
This commit is contained in:
teo_sarca 2008-02-19 06:19:03 +00:00
parent e2ca6313fa
commit 2dcbacf587
2 changed files with 7 additions and 7 deletions

View File

@ -74,10 +74,9 @@ public class ModelValidationEngine
Query query = table.createQuery("IsActive='Y'", null); Query query = table.createQuery("IsActive='Y'", null);
query.setOrderBy("SeqNo"); query.setOrderBy("SeqNo");
try { try {
List<PO> entityTypes = query.list(); List<X_AD_ModelValidator> entityTypes = query.list();
for (PO po : entityTypes) for (X_AD_ModelValidator entityType : entityTypes)
{ {
X_AD_ModelValidator entityType = (X_AD_ModelValidator)po;
String className = entityType.getModelValidationClass(); String className = entityType.getModelValidationClass();
if (className == null || className.length() == 0) if (className == null || className.length() == 0)
continue; continue;

View File

@ -27,6 +27,7 @@ import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DBException;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
@ -86,8 +87,8 @@ public class Query {
* @return List * @return List
* @throws SQLException * @throws SQLException
*/ */
public List<PO> list() throws SQLException { public <T extends PO> List<T> list() throws DBException {
List<PO> list = new ArrayList<PO>(); List<T> list = new ArrayList<T>();
POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID(), trxName); POInfo info = POInfo.getPOInfo(Env.getCtx(), table.getAD_Table_ID(), trxName);
if (info == null) return null; if (info == null) return null;
@ -117,14 +118,14 @@ public class Query {
rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
{ {
PO po = table.getPO(rs, trxName); T po = (T)table.getPO(rs, trxName);
list.add(po); list.add(po);
} }
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
throw e; throw new DBException(e);
} finally { } finally {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null; pstmt = null; rs = null; pstmt = null;