From 7821230d9c45ccc90919a9f42ef159f96b49eb81 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 14 Feb 2008 22:28:38 +0000 Subject: [PATCH] BF [ 1874419 ] JDBC Statement not close in a finally block --- base/src/org/compiere/model/CalloutInOut.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/base/src/org/compiere/model/CalloutInOut.java b/base/src/org/compiere/model/CalloutInOut.java index 5fef0f21bd..f410ee09b8 100644 --- a/base/src/org/compiere/model/CalloutInOut.java +++ b/base/src/org/compiere/model/CalloutInOut.java @@ -198,11 +198,13 @@ public class CalloutInOut extends CalloutEngine + " AND p.C_BPartner_ID=c.C_BPartner_ID(+)" + " AND p.C_BPartner_ID=?"; // 1 + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, C_BPartner_ID.intValue()); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { //[ 1867464 ] @@ -234,14 +236,16 @@ public class CalloutInOut extends CalloutEngine false); }// } - rs.close(); - pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); return e.getLocalizedMessage(); } + finally + { + DB.close(rs, pstmt); + } return ""; } // bpartner @@ -269,11 +273,13 @@ public class CalloutInOut extends CalloutEngine + " LEFT OUTER JOIN M_Locator l ON (l.M_Warehouse_ID=w.M_Warehouse_ID AND l.IsDefault='Y') " + "WHERE w.M_Warehouse_ID=?"; // 1 + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, M_Warehouse_ID.intValue()); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { // Org @@ -291,14 +297,16 @@ public class CalloutInOut extends CalloutEngine Env.setContext(ctx, WindowNo, "M_Locator_ID", ii.intValue()); } } - rs.close(); - pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, sql, e); return e.getLocalizedMessage(); } + finally + { + DB.close(rs, pstmt); + } return ""; } // warehouse