From b0a302589c8d2e88b047edcef1a6ba864098275e Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 4 Feb 2008 23:12:49 +0000 Subject: [PATCH] BF [ 1874419 ] JDBC Statement not close in a finally block - fixed for MChangeLog * reorganize imports --- base/src/org/compiere/model/PO_Record.java | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/base/src/org/compiere/model/PO_Record.java b/base/src/org/compiere/model/PO_Record.java index 4be117d267..7743870dc8 100644 --- a/base/src/org/compiere/model/PO_Record.java +++ b/base/src/org/compiere/model/PO_Record.java @@ -16,9 +16,13 @@ *****************************************************************************/ package org.compiere.model; -import java.sql.*; -import java.util.logging.*; -import org.compiere.util.*; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.logging.Level; + +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; /** * Maintain AD_Table_ID/Record_ID contraint @@ -175,31 +179,23 @@ public class PO_Record { String sql = "SELECT AD_Table_ID, TableName FROM AD_Table WHERE IsView='N' ORDER BY 2"; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql, null); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); while (rs.next ()) { validate (rs.getInt(1), rs.getString(2)); } - rs.close (); - pstmt.close (); - pstmt = null; } catch (Exception e) { log.log (Level.SEVERE, sql, e); } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; + finally { + DB.close(rs, pstmt); + rs = null; pstmt = null; } } // validate