@Test public void testLoad() throws Exception { List<String> ls = db.load(descriptor); Assert.assertEquals(itemsCount, ls.size()); Assert.assertTrue(ls.contains("1")); Assert.assertTrue(ls.contains("2")); }
@Override public List<String> load(ThreatListDescriptor descriptor) throws IOException { checkTableForDescriptor(descriptor); String sql = "SELECT prefix FROM " + descriptor + " ORDER BY prefix"; try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery()) { List<String> result = new LinkedList<>(); while (rs.next()) { result.add(rs.getString(1)); } LOGGER.info("Loaded {} items", result.size()); return result; } catch (SQLException ex) { throw new IOException(ex); } }
SqlLocalDatabase implements LocalDatabase { @Override public List<String> load(ThreatListDescriptor descriptor) throws IOException { checkTableForDescriptor(descriptor); String sql = "SELECT prefix FROM " + descriptor + " ORDER BY prefix"; try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery()) { List<String> result = new LinkedList<>(); while (rs.next()) { result.add(rs.getString(1)); } LOGGER.info("Loaded {} items", result.size()); return result; } catch (SQLException ex) { throw new IOException(ex); } } }
SqlLocalDatabase implements LocalDatabase { @Override public List<String> load(ThreatListDescriptor descriptor) throws IOException { checkTableForDescriptor(descriptor); String sql = "SELECT prefix FROM " + descriptor + " ORDER BY prefix"; try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery()) { List<String> result = new LinkedList<>(); while (rs.next()) { result.add(rs.getString(1)); } LOGGER.info("Loaded {} items", result.size()); return result; } catch (SQLException ex) { throw new IOException(ex); } }  }
SqlLocalDatabase implements LocalDatabase { @Override public List<String> load(ThreatListDescriptor descriptor) throws IOException { checkTableForDescriptor(descriptor); String sql = "SELECT prefix FROM " + descriptor + " ORDER BY prefix"; try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery()) { List<String> result = new LinkedList<>(); while (rs.next()) { result.add(rs.getString(1)); } LOGGER.info("Loaded {} items", result.size()); return result; } catch (SQLException ex) { throw new IOException(ex); } }  @Override List<String> load(ThreatListDescriptor descriptor); @Override void persist(ThreatListDescriptor descriptor, List<String> hashes); @Override boolean contains(String hash, ThreatListDescriptor descriptor); @Override void clear(ThreatListDescriptor descriptor); }
SqlLocalDatabase implements LocalDatabase { @Override public List<String> load(ThreatListDescriptor descriptor) throws IOException { checkTableForDescriptor(descriptor); String sql = "SELECT prefix FROM " + descriptor + " ORDER BY prefix"; try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ResultSet rs = ps.executeQuery()) { List<String> result = new LinkedList<>(); while (rs.next()) { result.add(rs.getString(1)); } LOGGER.info("Loaded {} items", result.size()); return result; } catch (SQLException ex) { throw new IOException(ex); } }  @Override List<String> load(ThreatListDescriptor descriptor); @Override void persist(ThreatListDescriptor descriptor, List<String> hashes); @Override boolean contains(String hash, ThreatListDescriptor descriptor); @Override void clear(ThreatListDescriptor descriptor);  }