From a1c61ee9a864655e2371db6a1f9a590f550f363b Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 16 Mar 2013 00:16:37 +0800 Subject: [PATCH] IDEMPIERE-751 Zk: WAssignmentEditor leak database statement object. --- .../webui/editor/WAssignmentEditor.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java index a6922e22b1..1ac60bda88 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java @@ -30,13 +30,19 @@ import org.zkoss.zk.ui.event.Events; public class WAssignmentEditor extends WEditor implements ContextMenuListener { + private static final String RETRIEVE_RESOURCE_ASSIGNMENT_SQL = "SELECT r.Name,ra.AssignDateFrom,ra.Qty,uom.UOMSymbol " + + "FROM S_ResourceAssignment ra, S_Resource r, S_ResourceType rt, C_UOM uom " + + "WHERE ra.S_ResourceAssignment_ID=?" + + " AND ra.S_Resource_ID=r.S_Resource_ID" + + " AND r.S_ResourceType_ID=rt.S_ResourceType_ID" + + " and rt.C_UOM_ID=uom.C_UOM_ID"; + private final static CLogger log = CLogger.getCLogger(WAssignmentEditor.class); private static final String[] LISTENER_EVENTS = {Events.ON_CLICK}; private boolean m_readWrite; private Object m_value; - private PreparedStatement m_pstmt; private DateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.DateTime); private NumberFormat m_qtyFormat = DisplayType.getNumberFormat(DisplayType.Quantity); @@ -105,20 +111,14 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { return; } - // Statement - if (m_pstmt == null) - m_pstmt = DB.prepareStatement("SELECT r.Name,ra.AssignDateFrom,ra.Qty,uom.UOMSymbol " - + "FROM S_ResourceAssignment ra, S_Resource r, S_ResourceType rt, C_UOM uom " - + "WHERE ra.S_ResourceAssignment_ID=?" - + " AND ra.S_Resource_ID=r.S_Resource_ID" - + " AND r.S_ResourceType_ID=rt.S_ResourceType_ID" - + " and rt.C_UOM_ID=uom.C_UOM_ID", null); // - ResultSet rs = null; + PreparedStatement pstmt = null; + ResultSet rs = null; try { - m_pstmt.setInt(1, S_ResourceAssignment_ID); - rs = m_pstmt.executeQuery(); + pstmt = DB.prepareStatement(RETRIEVE_RESOURCE_ASSIGNMENT_SQL, null); + pstmt.setInt(1, S_ResourceAssignment_ID); + rs = pstmt.executeQuery(); if (rs.next()) { StringBuilder sb = new StringBuilder(rs.getString(1)); @@ -136,7 +136,7 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener { } finally { - DB.close(rs); + DB.close(rs, pstmt); } }