ps = conn.prepareStatement(loadReferenceInfo);
List refs = new ArrayList();
   public List getReferenceInfos(long channelID, int number) throws Exception   {      if (trace)      {         log.trace("loading message reference info for channel " + channelID + " for " + number + " refs");      }            Connection conn = null;      PreparedStatement ps = null;      ResultSet rs = null;      TransactionWrapper wrap = new TransactionWrapper();            try      {         //First we select the references                  conn = ds.getConnection();                  ps = conn.prepareStatement(loadReferenceInfo);                  ps.setLong(1, channelID);                  if (trace)         {            log.trace(JDBCUtil.statementToString(loadReferenceInfo));         }                  rs = ps.executeQuery();                  int totalRows = 0;                  List infos = new ArrayList();                  while (totalRows < number && rs.next())         {            long msgId = rs.getLong(1);            long ordering = rs.getLong(2);            int deliveryCount = rs.getInt(3);                        ReferenceInfo ri = new ReferenceInfo(msgId, ordering, deliveryCount);                        infos.add(ri);                        totalRows++;         }                  return infos;      }      catch (Exception e)      {         wrap.exceptionOccurred();         throw e;      }      finally      {         if (rs != null)         {            try            {               rs.close();            }            catch (Throwable e)            {            }         }         if (ps != null)         {            try            {               ps.close();            }            catch (Throwable e)            {            }         }         if (conn != null)         {            try            {               conn.close();            }            catch (Throwable e)            {            }         }         wrap.end();      }   }