if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(deleteMessage, messageID) + " deleted " + rows + " row(s)"); }
if (trace) { log.trace(JDBCUtil.statementToString(deleteMessage, messageID) + " deleted " + rows + " row(s)"); }
   public boolean removeMessage(String messageID) throws Exception   {      Connection conn = null;      PreparedStatement ps = null;      TransactionWrapper wrap = new TransactionWrapper();      try      {         conn = ds.getConnection();         // get the reference count from the database         ps = conn.prepareStatement(selectReferenceCount);         ps.setString(1, messageID);         //TODO this can be combined into one query         int referenceCount = 0;         ResultSet rs = ps.executeQuery();         if (rs.next())         {            referenceCount = rs.getInt(1);         }         if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(selectReferenceCount, messageID) + " returned " + (referenceCount == 0 ? "no rows" : Integer.toString(referenceCount))); }         if (referenceCount == 0)         {            if (log.isTraceEnabled()) { log.trace("no message " + messageID + " to delete in the database"); }            return false;         }         else if (referenceCount == 1)         {            // physically delete the row in the database            ps = conn.prepareStatement(deleteMessage);            ps.setString(1, messageID);            int rows = ps.executeUpdate();            if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(deleteMessage, messageID) + " deleted " + rows + " row(s)"); }            return rows == 1;         }         else         {            // decrement the reference count            ps = conn.prepareStatement(updateReferenceCount);            ps.setInt(1, --referenceCount);            ps.setString(2, messageID);            ps.executeUpdate();            if (log.isTraceEnabled()) { log.trace(JDBCUtil.statementToString(updateReferenceCount, new Integer(referenceCount), messageID) + " executed successfully"); }            return true;         }      }      catch (Exception e)      {         wrap.exceptionOccurred();         throw e;      }      finally      {         if (ps != null)         {            try            {               ps.close();            }            catch (Throwable e)            {}         }         if (conn != null)         {            try            {               conn.close();            }            catch (Throwable e)            {}         }         wrap.end();     }   }