if (log.isTraceEnabled()) { log.trace("Adding delivery " + d + " to channel: "  + channelID);}  Connection conn = null;
if (log.isTraceEnabled()) { log.trace("Adding delivery " + d + " to channel: " + channelID); }
   public void addDelivery(Serializable channelID, Delivery d) throws Exception   {      if (log.isTraceEnabled()) { log.trace("Adding delivery " + d + " to channel: "  + channelID);}      Connection conn = null;      PreparedStatement ps = null;      TransactionWrapper wrap = new TransactionWrapper();      MessageReference ref = null;      String messageID = null;      String receiverID = "";      String storeID = null;      try      {         ref = d.getReference();         messageID = (String)ref.getMessageID();         if (d instanceof StatefulReceiverDelivery)         {            receiverID = (String)((StatefulReceiverDelivery)d).getReceiverID();         }         storeID = (String)ref.getStoreID();         conn = ds.getConnection();         ps = conn.prepareStatement(insertDelivery);         ps.setString(1, (String)channelID);         ps.setString(2, messageID);         ps.setString(3, receiverID);         ps.setString(4, storeID);         ps.setNull(5, java.sql.Types.VARCHAR);         ps.setString(6, "C");         int rows = ps.executeUpdate();         if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(insertDelivery, channelID, messageID, receiverID, storeID, null, "C") + " inserted " + rows + " row(s)"); }      }      catch (SQLException e)      {         if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(insertDelivery, channelID, messageID, receiverID, storeID, null, "C") + " failed"); }         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();      }   }