From b76998a7a276ced7fc75c2ef0d5752a7cecd2d14 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Tue, 19 Feb 2008 13:25:57 +0000 Subject: [PATCH] *BF [ 1874419 ] JDBC Statement not close in a finally block organize imports --- .../src/org/compiere/acct/Doc_Allocation.java | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/base/src/org/compiere/acct/Doc_Allocation.java b/base/src/org/compiere/acct/Doc_Allocation.java index 354192cf37..6bbabb48f3 100644 --- a/base/src/org/compiere/acct/Doc_Allocation.java +++ b/base/src/org/compiere/acct/Doc_Allocation.java @@ -16,12 +16,25 @@ *****************************************************************************/ package org.compiere.acct; -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.logging.*; -import org.compiere.model.*; -import org.compiere.util.*; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.logging.Level; + +import org.compiere.model.MAccount; +import org.compiere.model.MAcctSchema; +import org.compiere.model.MAllocationHdr; +import org.compiere.model.MAllocationLine; +import org.compiere.model.MCashLine; +import org.compiere.model.MConversionRate; +import org.compiere.model.MFactAcct; +import org.compiere.model.MInvoice; +import org.compiere.model.MInvoiceLine; +import org.compiere.model.MPayment; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; /** * Post Allocation Documents. @@ -550,11 +563,12 @@ public class Doc_Allocation extends Doc + "FROM C_Payment p INNER JOIN C_DocType d ON (p.C_DocType_ID=d.C_DocType_ID) " + "WHERE C_Payment_ID=?"; PreparedStatement pstmt = null; + ResultSet rs = null; try { pstmt = DB.prepareStatement (sql, getTrxName()); pstmt.setInt (1, C_Payment_ID); - ResultSet rs = pstmt.executeQuery (); + rs = pstmt.executeQuery (); if (rs.next ()) { setC_BankAccount_ID(rs.getInt(1)); @@ -569,23 +583,15 @@ public class Doc_Allocation extends Doc accountType = Doc.ACCTTYPE_V_Prepayment; } } - rs.close (); - pstmt.close (); - pstmt = null; - } + } catch (Exception e) { log.log(Level.SEVERE, sql, e); } - try + finally { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; + DB.close(rs, pstmt); + rs = null; pstmt = null; } //