if (removed)
int rows = psUpdateMessage.executeUpdate();  if (trace)
   protected void handleBeforeRollback(List refsToAdd, Transaction tx) throws Exception   {      //remove refs marked with +      //and update rows marked with - to C                  PreparedStatement psDeleteMessage = null;      PreparedStatement psUpdateMessage = null;      Connection conn = null;      TransactionWrapper wrap = new TransactionWrapper();            try      {         conn = ds.getConnection();                  rollbackPreparedTransaction(tx, conn);                  Iterator iter = refsToAdd.iterator();                  boolean batch = usingBatchUpdates && refsToAdd.size() > 1;         boolean messageDeletionsInBatch = false;         boolean messageUpdatesInBatch = false;         if (batch)         {            psDeleteMessage = conn.prepareStatement(deleteMessage);            psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);         }                                          while (iter.hasNext())         {            ChannelRefPair pair = (ChannelRefPair) iter.next();                        if (!batch)            {               psDeleteMessage = conn.prepareStatement(deleteMessage);               psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);            }                        Message m = pair.ref.getMessage();                        synchronized (m)            {                                 //We may need to remove the message for messages added during the prepare stage                              m.decPersistentChannelCount();                              boolean removed;               if (m.getPersistentChannelCount() == 0)               {                  //remove message                  removeMessage(m, psDeleteMessage);                                    removed = true;                                   }               else               {                  //update message channel count                  updateMessageChannelCount(m, psUpdateMessage);                                    removed = false;               }                                                if (batch)               {                  if (removed)                  {                     psDeleteMessage.addBatch();                     messageDeletionsInBatch = true;                  }                  else                  {                     psUpdateMessage.addBatch();                     messageUpdatesInBatch = true;                  }               }               else               {                  if (removed)                  {                     int rows = psDeleteMessage.executeUpdate();                                          if (trace)                     {                        log.trace("deleted " + rows + " rows");                     }                  }                  else                  {                     int rows = psUpdateMessage.executeUpdate();                                          if (trace)                     {                        log.trace("updated " + rows + " rows");                     }                  }                  psDeleteMessage.close();                  psDeleteMessage = null;                  psUpdateMessage.close();                  psUpdateMessage = null;               }            }         }                  if (batch)         {            if (messageDeletionsInBatch)            {               int[] rows = psDeleteMessage.executeBatch();                              if (trace)               {                  logBatchUpdate(deleteMessage, rows, "deleted");               }                              psDeleteMessage.close();               psDeleteMessage = null;            }            if (messageUpdatesInBatch)            {               int[] rows = psUpdateMessage.executeBatch();                              if (trace)               {                  logBatchUpdate(updateMessageChannelCount, rows, "updated");               }                              psUpdateMessage.close();               psUpdateMessage = null;            }         }      }      catch (Exception e)      {         wrap.exceptionOccurred();         throw e;      }      finally      {         if (psDeleteMessage != null)         {            try            {               psDeleteMessage.close();            }            catch (Throwable t)            {            }         }         if (psUpdateMessage != null)         {            try            {               psUpdateMessage.close();            }            catch (Throwable t)            {            }         }         if (conn != null)         {            try            {               conn.close();            }            catch (Throwable e)            {            }         }         wrap.end();      }         }