Connection conn = ds.getConnection();
Connection conn = getConnection();  Message m = ref.getMessage();  boolean decremented = false;
   public void removeReference(long channelID, MessageReference ref, Transaction tx) throws Exception   {            if (tx != null)      {         //In a tx so we just add the ref in the tx in memory for now         TransactionCallback callback = getCallback(tx);         callback.addReferenceToRemove(channelID, ref);      }      else      {                  //No tx so we remove the reference directly from the db                  TransactionWrapper wrap = new TransactionWrapper();                  PreparedStatement psReference = null;         PreparedStatement psMessage = null;                  Connection conn = ds.getConnection();         try         {            Message m = ref.getMessage();                                                 psReference = conn.prepareStatement(deleteMessageRef);                        //Remove the message reference            removeReference(channelID, ref, psReference);                        int rows = psReference.executeUpdate();                        if (trace)            {               log.trace("Deleted " + rows + " rows");            }                           synchronized (m)            {                              m.decPersistentChannelCount();                              if (m.getPersistentChannelCount() == 0)               {                  //No other channels have a reference so we can delete the message                  psMessage = conn.prepareStatement(deleteMessage);                                                      removeMessage(m, psMessage);               }               else               {                  //Other channel(s) still have hold references so update the channel count                  psMessage = conn.prepareStatement(updateMessageChannelCount);                                    updateMessageChannelCount(m, psMessage);               }                                             rows = psMessage.executeUpdate();                              if (trace)               {                  log.trace("Delete/updated " + rows + " rows");               }                           }         }         catch (Exception e)         {            wrap.exceptionOccurred();            throw e;         }         finally         {            if (psReference != null)            {               try               {                  psReference.close();               }               catch (Throwable t)               {               }            }            if (psMessage != null)            {               try               {                  psMessage.close();               }               catch (Throwable t)               {               }            }            if (conn != null)            {               try               {                  conn.close();               }               catch (Throwable t)               {               }            }            wrap.end();         }            }   }