From 920c5f51ea4e90367cf376cdb53bf55675cbdee2 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Thu, 24 Jan 2008 10:12:25 +0000 Subject: [PATCH] BF [ 1874419 ] JDBC Statement not close in a finally block --- base/src/org/compiere/print/MPrintFormatItem.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/base/src/org/compiere/print/MPrintFormatItem.java b/base/src/org/compiere/print/MPrintFormatItem.java index 5b3f47cddc..519f0d528c 100644 --- a/base/src/org/compiere/print/MPrintFormatItem.java +++ b/base/src/org/compiere/print/MPrintFormatItem.java @@ -424,7 +424,7 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem */ public static MPrintFormatItem createFromColumn (MPrintFormat format, int AD_Column_ID, int seqNo) { - MPrintFormatItem pfi = new MPrintFormatItem (format.getCtx(), 0, null); + MPrintFormatItem pfi = new MPrintFormatItem (format.getCtx(), 0, format.get_TrxName()); pfi.setAD_PrintFormat_ID (format.getAD_PrintFormat_ID()); pfi.setClientOrg(format); pfi.setAD_Column_ID(AD_Column_ID); @@ -446,13 +446,15 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem + "WHERE c.AD_Column_ID=?" + " AND c.AD_Element_ID=e.AD_Element_ID" + " AND e.AD_Language=?"; + PreparedStatement pstmt = null; + ResultSet rs = null; try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, format.get_TrxName()); pstmt.setInt(1, AD_Column_ID); if (trl) pstmt.setString(2, language.getAD_Language()); - ResultSet rs = pstmt.executeQuery(); + rs = pstmt.executeQuery(); if (rs.next()) { String ColumnName = rs.getString(1); @@ -494,13 +496,15 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem else s_log.log(Level.SEVERE, "Not Found AD_Column_ID=" + AD_Column_ID + " Trl=" + trl + " " + language.getAD_Language()); - rs.close(); - pstmt.close(); } catch (SQLException e) { s_log.log(Level.SEVERE, sql, e); } + finally { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } if (!pfi.save()) return null; // pfi.dump();