if (conn != null) { try { conn.close(); } catch (Throwable e) { } } wrap.end();
   protected void handleBeforeRollback(boolean onePhase, List refsToAdd, Transaction tx) throws Exception   {      //if one phase then do nothing (there is nothing in the db)      //if two phase then remove refs marked with +      //and update rows marked with - to C      if (onePhase)      {         //NOOP      }      else      {         PreparedStatement psMessage = 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 messagesInBatch = false;            if (batch)            {               psMessage = conn.prepareStatement(deleteMessage);            }            while (iter.hasNext())            {               ChannelRefPair pair = (ChannelRefPair) iter.next();               if (!batch)               {                  psMessage = conn.prepareStatement(deleteMessage);               }               //We may need to remove the message for messages added during the prepare stage               boolean removed = checkRemoveMessage(pair.ref, psMessage);               if (batch)               {                  if (removed)                  {                     psMessage.addBatch();                     messagesInBatch = true;                  }               }               else               {                  if (removed)                  {                     int rows = psMessage.executeUpdate();                     if (trace)                     {                        log.trace("deleted " + rows + " rows");                     }                  }                  psMessage.close();                  psMessage = null;               }            }            if (batch)            {               if (messagesInBatch)               {                  int[] rows = psMessage.executeBatch();                  if (trace)                  {                     logBatchUpdate(deleteMessage, rows, "deleted");                  }                  psMessage.close();                  psMessage = null;               }            }         }         catch (Exception e)         {            wrap.exceptionOccurred();            throw e;         }         finally         {            if (psMessage != null)            {               try               {                  psMessage.close();               }               catch (Throwable t)               {               }            }            if (conn != null)            {               try               {                  conn.close();               }               catch (Throwable e)               {               }            }            wrap.end();         }      }   }