### Question:
JdbcSourceDriver implements SourceDriver<T> { @Override public void prepare() throws IOException { LOG.debug("Preparing JDBC resource source (resource={}, table={})", profile.getResourceName(), script.getTableName()); try { this.resultSet = prepareResultSet(); } catch (SQLException e) { for (SQLException ex = e; ex != null; ex = ex.getNextException()) { WGLOG.error(ex, "E03001", profile.getResourceName(), script.getName(), script.getTableName(), script.getColumnNames()); } throw new IOException(MessageFormat.format( "Failed to prepare JDBC source (resource={0}, table={1}, columns={2})", profile.getResourceName(), script.getTableName(), script.getColumnNames()), e); } LOG.debug("Creating ResultSet support {} for {}", script.getSupport().getClass().getName(), script.getColumnNames()); support = script.getSupport().createResultSetSupport(resultSet, script.getColumnNames()); } JdbcSourceDriver(
            JdbcProfile profile,
            JdbcScript<T> script,
            Connection connection,
            T object); @Override void prepare(); @Override boolean next(); @Override T get(); @Override void close();  }### Answer:
@Test public void simple() throws Exception { h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (1, 'Hello, world!')"); try (Connection conn = h2.open()) { JdbcScript<Pair> script = new JdbcScript<>( "testing", new PairSupport(), "PAIR", Arrays.asList("KEY", "VALUE"), null); try (JdbcSourceDriver<Pair> driver = new JdbcSourceDriver<>(profile(), script, conn, new Pair())) { driver.prepare(); List<String> values = values(driver); assertThat(values, is(Arrays.asList("Hello, world!"))); } } }
@Test public void empty() throws Exception { try (Connection conn = h2.open()) { JdbcScript<Pair> script = new JdbcScript<>( "testing", new PairSupport(), "PAIR", Arrays.asList("KEY", "VALUE"), null); try (JdbcSourceDriver<Pair> driver = new JdbcSourceDriver<>(profile(), script, conn, new Pair())) { driver.prepare(); List<String> values = values(driver); assertThat(values, is(Collections.emptyList())); } } }
@Test public void large() throws Exception { List<String> answer = new ArrayList<>(); for (int i = 0; i < 3000; i++) { String value = MessageFormat.format( "Hello{0}", String.valueOf(i + 1)); answer.add(value); h2.execute(MessageFormat.format( "INSERT INTO PAIR (KEY, VALUE) VALUES ({0}, ''{1}'')", String.valueOf(i + 1), value)); } try (Connection conn = h2.open()) { JdbcScript<Pair> script = new JdbcScript<>( "testing", new PairSupport(), "PAIR", Arrays.asList("KEY", "VALUE"), null); try (JdbcSourceDriver<Pair> driver = new JdbcSourceDriver<>(profile(), script, conn, new Pair())) { driver.prepare(); List<String> values = values(driver); assertThat(values, is(answer)); } } }
@Test public void condition() throws Exception { for (int i = 0; i < 100; i++) { String value = MessageFormat.format( "Hello{0}", String.valueOf(i + 1)); h2.execute(MessageFormat.format( "INSERT INTO PAIR (KEY, VALUE) VALUES ({0}, ''{1}'')", String.valueOf(i + 1), value)); } try (Connection conn = h2.open()) { JdbcScript<Pair> script = new JdbcScript<>( "testing", new PairSupport(), "PAIR", Arrays.asList("KEY", "VALUE"), "KEY BETWEEN 80 AND 81"); try (JdbcSourceDriver<Pair> driver = new JdbcSourceDriver<>(profile(), script, conn, new Pair())) { driver.prepare(); List<String> values = values(driver); assertThat(values, is(Arrays.asList("Hello80", "Hello81"))); } } }