@Test public void testList() throws SQLException { JdbcDataSource ds = new JdbcDataSource(); ds.setUrl("jdbc:h2:mem:person;DB_CLOSE_DELAY=-1"); new Migrator().prepare(ds); PersonRepo personRepo = new PersonRepo(); personRepo.ds = ds; List<Person> persons = personRepo.list(); Person person = persons.iterator().next(); Assert.assertEquals(1, person.id); Assert.assertEquals("Chris", person.name); }
public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } }
PersonRepo { public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } } }
PersonRepo { public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } }  }
PersonRepo { public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } }  List<Person> list(); }
PersonRepo { public List<Person> list() { try (Connection con = ds.getConnection()) { ArrayList<Person> persons = new ArrayList<Person>(); ResultSet rs = con.createStatement().executeQuery(QUERY); while (rs.next()) { persons.add(read(rs)); } return persons; } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } }  List<Person> list();  }