From 4f3b666ef4f8853c41aeb34ddc8bcd916fbcdfc4 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Fri, 1 Feb 2008 10:34:10 +0000 Subject: [PATCH] Bugs-1874419 ] JDBC Statement not close in a finally block Trying out with one case for review. If ok, will do the rest --- client/src/org/compiere/apps/AArchive.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/client/src/org/compiere/apps/AArchive.java b/client/src/org/compiere/apps/AArchive.java index 3fd4c9252b..ef05a52840 100644 --- a/client/src/org/compiere/apps/AArchive.java +++ b/client/src/org/compiere/apps/AArchive.java @@ -90,6 +90,7 @@ public class AArchive implements ActionListener sql.append(" OR C_BPartner_ID=?"); sql.append(" GROUP BY IsReport"); PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql.toString(), null); @@ -97,7 +98,7 @@ public class AArchive implements ActionListener pstmt.setInt(2, m_Record_ID); if (m_AD_Table_ID == MBPartner.Table_ID) pstmt.setInt(3, m_Record_ID); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); while (rs.next ()) { if ("Y".equals(rs.getString(1))) @@ -113,16 +114,12 @@ public class AArchive implements ActionListener { log.log(Level.SEVERE, sql.toString(), e); } - try + finally { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; } + // if (documentCount > 0) {