deleteAll() 에 적용하기

public void deleteAll() throws SQLException {
    this.jdbcTemplate.update(
        new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
            return con.prepareStatement("delete from users");
          }
        }
    );
  }
  public void deleteAll() throws SQLException {
    this.jdbcTemplate.update("delete from users");
  }

<aside> 💡

update() 의 파라미터 유형

  1. 콜백
  2. SQL 문(String)

</aside>

add() 메서드에 적용하기

⇒ JdbcTemplate 에서 제공하는 메서드로 변환해보자

public void add(final User user) throws SQLException {
  this.jdbcTemplate.update("insert into users(id, name, password) values(?,?,?)", user.getId(), user.getName(), user.getPassword());
}