From 1cfcf92f6afd8bcf0c87f01c2ab7c92d32c136aa Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 14 Feb 2008 23:05:06 +0000 Subject: [PATCH] BF [ 1874419 ] JDBC Statement not close in a finally block --- base/src/org/compiere/model/MWindow.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/base/src/org/compiere/model/MWindow.java b/base/src/org/compiere/model/MWindow.java index df421d8d37..a1a11998d1 100644 --- a/base/src/org/compiere/model/MWindow.java +++ b/base/src/org/compiere/model/MWindow.java @@ -220,21 +220,25 @@ public class MWindow extends X_AD_Window public static int getWindow_ID(String windowName) { int retValue = 0; String SQL = "SELECT AD_Window_ID FROM AD_Window WHERE Name = ?"; + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(SQL, null); + pstmt = DB.prepareStatement(SQL, null); pstmt.setString(1, windowName); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) retValue = rs.getInt(1); - rs.close(); - pstmt.close(); } catch (SQLException e) { s_log.log(Level.SEVERE, SQL, e); retValue = -1; } + finally + { + DB.close(rs, pstmt); + } return retValue; } //end vpj-cd e-evolution