/** * Reads active registry entries assigned to this server. * * @return the list of the active registry entries associated to this server * @throws com.funambol.pushlistener.service.registry.dao.DataAccessException if an error occurs */ public List<RegistryEntry> getActiveEntries() throws DataAccessException { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; List<RegistryEntry> entries = new ArrayList<RegistryEntry>(); try { if (log.isTraceEnabled()) { log.trace("Executing '" + queryDesc.getReadActiveEntriesQuery() + "'"); } con = getConnection(); con.setReadOnly(true); ps = con.prepareStatement(queryDesc.getReadActiveEntriesQuery()); ps.setString(1, "Y"); rs = ps.executeQuery(); while (rs.next()) { entries.add(resultSetToRegistryEntry(rs)); } } catch (Exception e) { throw new DataAccessException(e); } finally { DBTools.close(con, ps, rs); } return entries; }
/** * Reads registry entries assigned to this server. If <code>lastUpdate</code> is different than 0, * just the changed entries with last_update bigger than the given one and the given status are * returned. * * @param lastUpdate the lastUpdate. 0 if all entries must be returned * @param status the wanted status * @throws com.funambol.pushlistener.service.registry.dao.DataAccessException if an error occurs * @return the read entries */ public List<RegistryEntry> getEntries(long lastUpdate, String status) throws DataAccessException { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; List<RegistryEntry> entries = new ArrayList<RegistryEntry>(); try { con = getConnection(); con.setReadOnly(true); if (lastUpdate != 0) { // // Read only changed registry entries // if (log.isTraceEnabled()) { log.trace("Executing '" + queryDesc.getReadChangedEntriesQuery() + "'"); } ps = con.prepareStatement(queryDesc.getReadChangedEntriesQuery()); ps.setLong(1, lastUpdate); ps.setString(2, status); } else { // // Read all registry entries // if (log.isTraceEnabled()) { log.trace("Executing '" + queryDesc.getReadActiveEntriesQuery() + "'"); } ps = con.prepareStatement(queryDesc.getReadActiveEntriesQuery()); ps.setString(1, "Y"); } rs = ps.executeQuery(); while (rs.next()) { entries.add(resultSetToRegistryEntry(rs)); } } catch (Exception e) { throw new DataAccessException(e); } finally { DBTools.close(con, ps, rs); } return entries; }