if (log.isTraceEnabled()) { log.trace("Removing delivery " + d + " from channel: "  + channelID);}
if (log.isTraceEnabled()) { log.trace("Removing delivery " + d + " from channel: "  + channelID + (tx == null ? " non-transactionally" : " on transaction: " + tx));}
   public boolean remove(Serializable channelID, Delivery d, Transaction tx) throws Exception   {      if (log.isTraceEnabled()) { log.trace("Removing delivery " + d + " from channel: "  + channelID);}                  Connection conn = null;      PreparedStatement ps = null;            TransactionWrapper wrap = new TransactionWrapper();            try      {         conn = ds.getConnection();                  insertTx(conn, tx);                  int updated;         String sql;                  if (tx == null)         {            //Non transacted case            sql = "DELETE FROM DELIVERY WHERE CHANNELID=? AND MESSAGEID=? AND STATE='C'";                  ps = conn.prepareStatement(sql);            ps.setString(1, (String)channelID);            ps.setString(2, (String)d.getReference().getMessageID());                        updated = ps.executeUpdate();         }         else         {            //Transacted case            sql = "UPDATE DELIVERY SET TRANSACTIONID=?, STATE='-' WHERE CHANNELID=? AND MESSAGEID=? AND STATE='C'";            ps = conn.prepareStatement(sql);            ps.setString(1, String.valueOf(tx.getID()));            ps.setString(2, (String)d.getReference().getStoreID());            ps.setString(3, (String)d.getReference().getMessageID());                        updated = ps.executeUpdate();                     }                  if (log.isTraceEnabled())         {            log.trace(sql);            log.trace("Removed/updated " + updated + " rows");         }                           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();      }   }