@Test void update() throws SQLException { when(preparedStatement.executeUpdate()).thenReturn(5); JdbcSqlExecutor sut = JdbcSqlExecutor.of(dataSource); String sql = "update foo set num = ?"; int result = sut.update(connection, sql, toArray(3)); verify(connection).prepareStatement(sql); verify(preparedStatement).executeUpdate(); verify(preparedStatement).setObject(1, 3); verify(preparedStatement).close(); verifyNoMoreInteractions(connection, preparedStatement, resultSet, rowMapper); assertThat(result, is(5)); }
@Override public int update(String sql, Object[] args) { try (CompositeAutoCloseable autoCloseable = new CompositeAutoCloseable()) { Connection connection = autoCloseable.add(connect()); return update(connection, sql, args); } }
JdbcSqlExecutor implements SqlExecutor { @Override public int update(String sql, Object[] args) { try (CompositeAutoCloseable autoCloseable = new CompositeAutoCloseable()) { Connection connection = autoCloseable.add(connect()); return update(connection, sql, args); } } }
JdbcSqlExecutor implements SqlExecutor { @Override public int update(String sql, Object[] args) { try (CompositeAutoCloseable autoCloseable = new CompositeAutoCloseable()) { Connection connection = autoCloseable.add(connect()); return update(connection, sql, args); } } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); }
JdbcSqlExecutor implements SqlExecutor { @Override public int update(String sql, Object[] args) { try (CompositeAutoCloseable autoCloseable = new CompositeAutoCloseable()) { Connection connection = autoCloseable.add(connect()); return update(connection, sql, args); } } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); @Override Dialect dialect(); @Override JdbcTransaction beginTransaction(); @Override DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable); @Override List<T> query(String sql, Object[] args, RowMapper<T> rowMapper); @Override Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper); @Override int update(String sql, Object[] args); CompletableFuture<Integer> updateAsync(Connection connection, String sql, Object[] args); static JdbcSqlExecutor of(DataSource dataSource); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize); static JdbcSqlExecutor of(DataSource dataSource, Executor executor); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize, Executor executor); }
JdbcSqlExecutor implements SqlExecutor { @Override public int update(String sql, Object[] args) { try (CompositeAutoCloseable autoCloseable = new CompositeAutoCloseable()) { Connection connection = autoCloseable.add(connect()); return update(connection, sql, args); } } private  JdbcSqlExecutor(DataSource dataSource, int fetchSize, Executor executor); @Override Dialect dialect(); @Override JdbcTransaction beginTransaction(); @Override DatabaseMetaData metadata(CompositeAutoCloseable autoCloseable); @Override List<T> query(String sql, Object[] args, RowMapper<T> rowMapper); @Override Stream<T> stream(String sql, Object[] args, RowMapper<T> rowMapper); @Override int update(String sql, Object[] args); CompletableFuture<Integer> updateAsync(Connection connection, String sql, Object[] args); static JdbcSqlExecutor of(DataSource dataSource); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize); static JdbcSqlExecutor of(DataSource dataSource, Executor executor); static JdbcSqlExecutor of(DataSource dataSource, int fetchSize, Executor executor);  }