From 6bcf6c444d1167555e9dc5b61711f7ba7162f2f2 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Thu, 3 Jul 2008 14:38:40 +0000 Subject: [PATCH] BF [ 1874419 ] JDBC Statement not close in a finally block --- base/src/org/compiere/FA/Depreciation.java | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/base/src/org/compiere/FA/Depreciation.java b/base/src/org/compiere/FA/Depreciation.java index a2f64c9e2d..e77495f1cb 100644 --- a/base/src/org/compiere/FA/Depreciation.java +++ b/base/src/org/compiere/FA/Depreciation.java @@ -728,8 +728,9 @@ public class Depreciation { //System.out.println("SYD: "+sqlB.toString()); PreparedStatement pstmt = null; pstmt = DB.prepareStatement (sqlB.toString(),null); + ResultSet rs = null; try { - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); while (rs.next()){ int v_life_current_year = (int)(p_A_CURRENT_PERIOD/(12))+1; @@ -749,14 +750,8 @@ public class Depreciation { } finally { - try - { - if (pstmt != null) - pstmt.close (); - } - catch (Exception e) - {} - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; } return A_Period_Exp; } @@ -782,8 +777,9 @@ public class Depreciation { //System.out.println("TAB: "+sqlB.toString()); PreparedStatement pstmt = null; pstmt = DB.prepareStatement (sqlB.toString(),null); + ResultSet rs = null; try { - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); while (rs.next()){ @@ -912,14 +908,9 @@ public class Depreciation { } finally { - try - { - if (pstmt != null) - pstmt.close (); - } - catch (Exception e) - {} - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; + } return A_Period_Exp; }