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.setOrderBy("SeqNo");
try {
List<PO> entityTypes = query.list();
for (PO po : entityTypes)
List<X_AD_ModelValidator> entityTypes = query.list();
for (X_AD_ModelValidator entityType : entityTypes)
{
X_AD_ModelValidator entityType = (X_AD_ModelValidator)po;
String className = entityType.getModelValidationClass();
if (className == null || className.length() == 0)
continue;

View File

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