List extraRefs = new ArrayList();
   public InitialLoadInfo getInitialReferenceInfos(long channelID, int fullSize) throws Exception   {      if (trace)      {         log.trace("loading initial reference infos for channel " + channelID);      }                          List refs = new ArrayList();      List extraRefs = new ArrayList();            Connection conn = null;      PreparedStatement ps = null;      ResultSet rs = null;      TransactionWrapper wrap = new TransactionWrapper();            try      {         conn = ds.getConnection();                           //First we get the values for min() and max() page order         ps = conn.prepareStatement(getSQLStatement("SELECT_MIN_MAX_PAGE_ORD"));                  ps.setLong(1, channelID);                  rs = ps.executeQuery();                           rs.next();                  Long minOrdering = new Long(rs.getLong(1));                  if (rs.wasNull())         {            minOrdering = null;         }                  Long maxOrdering = new Long(rs.getLong(2));                  if (rs.wasNull())         {            maxOrdering = null;         }                  ps = conn.prepareStatement(getSQLStatement("LOAD_UNPAGED_REFS"));                  ps.setLong(1, channelID);                          rs = ps.executeQuery();                  int count = 0;         while (rs.next())         {            long msgId = rs.getLong(1);                        int deliveryCount = rs.getInt(2);            boolean reliable = rs.getString(3).equals("Y");                        ReferenceInfo ri = new ReferenceInfo(msgId, deliveryCount, reliable);                        if (count < fullSize)            {               refs.add(ri);            }                                    count++;         }                           //No refs paged                     if (count > fullSize)         {            throw new IllegalStateException("Cannot load channel " + channelID + " since the fullSize parameter is too small to load " +                     " all the required references, fullSize needs to be at least " + count + " it is currently " + fullSize);         }                                  return new InitialLoadInfo(minOrdering, maxOrdering, refs);      }      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();      }         }   