if (conn != null) { try { conn.close(); } catch (Throwable t) {} } wrap.end();
   public boolean removeDelivery(Serializable channelID, Delivery d, Transaction tx) throws Exception   {      if (log.isTraceEnabled()) { log.trace("Removing delivery " + d + " from channel: "  + channelID + (tx == null ? " non-transactionally" : " on transaction: " + tx));}                  Connection conn = null;      PreparedStatement ps = null;      TransactionWrapper wrap = new TransactionWrapper();      try      {         conn = ds.getConnection();                  insertTx(conn, tx);         int updated;         String messageID = (String)d.getReference().getMessageID();         String receiverID = "";         if (d instanceof StatefulReceiverDelivery)         {            receiverID = (String)((StatefulReceiverDelivery)d).getReceiverID();         }         if (tx == null)         {            //Non transacted case            ps = conn.prepareStatement(deleteDelivery);            ps.setString(1, (String)channelID);            ps.setString(2, messageID);            ps.setString(3, receiverID);            updated = ps.executeUpdate();            if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(deleteDelivery, channelID, messageID, receiverID) + " removed/updated " + updated + " row(s)"); }         }         else         {            //Transacted case            ps = conn.prepareStatement(updateDelivery);            if (tx.getGuidTxId() != null)            {               ps.setString(1, tx.getGuidTxId());            }            else            {               ps.setLong(1, tx.getLongTxId());            }            ps.setString(2, (String)channelID);            ps.setString(3, messageID);            ps.setString(4, receiverID);            updated = ps.executeUpdate();            if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(updateDelivery, getTxId(tx), channelID, messageID, receiverID) + " updated " + updated + " row(s)"); }         }         return updated == 1;      }      catch (SQLException e)      {         wrap.exceptionOccurred();         throw e;      }      finally      {         if (ps != null)         {            try            {               ps.close();            }            catch (Throwable t)            {}         }         if (conn != null)         {            try            {               conn.close();            }            catch (Throwable t)            {}         }         wrap.end();      }   }