title: Using Spring NamedParameterJdbcTemplate, how can I update a column for every customer in the database?
body: <p>I am trying to create a function that updates every customer in a database called customers (the lastEmailed column), and I have tried multiple times using different query inputs, and execution methods (update, batchupdate, etc) and I am having no luck. This is what my chopped/commented code looks like, after messing around. Any suggestions would be greatly appreciated, thanks! Also, the input style is in the format 2014-12-09 14:20:47 (datetime). ** this is a NamedParameterJdbcTemplate.</p>
  
  <p>** this refers in particular to the updateTime function, I just included the rest of my DAO to help
  ** I want to update EVERY customer with the same value for lastEmailed only, every time the function is called.</p>
  
  <pre><code>@Repository            // creates the bean
  public class CustomerDAO {
  
  @Autowired
  private NamedParameterJdbcTemplate jdbcTemplate;
  
  private RowMapper&lt;Customer&gt; rowMapper = new RowMapper&lt;Customer&gt;() {
      @Override
      public Customer mapRow(ResultSet resultSet, int index) throws SQLException {
          Customer customer = new Customer();
          customer.setCustomerNumber(resultSet.getString("id"));
          customer.setFirstName(resultSet.getString("fName"));
          customer.setLastName(resultSet.getString("lName"));
          customer.setEmail(resultSet.getString("email"));
          customer.setStreet(resultSet.getString("street"));
          customer.setCity(resultSet.getString("city"));
          customer.setState(resultSet.getString("state"));
          customer.setZip(resultSet.getString("zip"));
  
          //Map Customer Fields Here
  
          return customer;
      }
  };
  public List&lt;Customer&gt; getCustomerList(){
      String sql = "SELECT * FROM CUSTOMERS";
      List&lt;Customer&gt; customerList =this.jdbcTemplate.query(sql, rowMapper);
      return customerList;
  }
  
   // ** in another class?
   //    public String toString(){
  //        List&lt;Customer&gt; temp = this.getCustomerList();
   //
   //    }
  
  public void saveCustomer(Customer customer) {
      String sql = "INSERT INTO CUSTOMERS " +
              "(id, lname, fname, email, street,city, state,zip) VALUES (:id, :lname, :fname, :email, " +
              ":street, :city, :state, :zip)";
  
      Map&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;();
      parameters.put("id", customer.getCustomerNumber());
      parameters.put("lname", customer.getLastName());
      parameters.put("fname", customer.getFirstName());
      parameters.put("email", customer.getEmail());
      parameters.put("street", customer.getStreet());
      parameters.put("city", customer.getCity());
      parameters.put("state", customer.getState());
      parameters.put("zip", customer.getZip());
      this.jdbcTemplate.update(sql, parameters);
  
  }
  
  public void updateTime(String timeSent){
      String query = "UPDATE customers SET lastEmailed ='" + timeSent+"'";
  //        String query = "UPDATE customers SET lastEmailed = ?";
  //         String query = "INSERT INTO CUSTOMERS "
  //        this.jdbcTemplate.
  //        this.jdbcTemplate.executeppr
  //        this.jdbcTemplate.update
  
  //         jdbcTemplate.update("UPDATE customers SET lastEmailed=?",timeSent);
  //        SqlParameterSource [] parameterSource =     SqlParameterSourceUtils.createBatch(this.getCustomerList().toArray());
  //        this.jdbcTemplate.batchUpdate("INSERT INTO CUSTOMERS (id,lastEmailed) VALUES     (:customerNumber, " +timeSent + ")", parameterSource);
  
  }
  }
  </code></pre>