1

I am trying to perform an UPDATE on a MySQL database where I update only one single column full of values corresponding to the correct index position. Here is my current code:

JdbcTemplate temp = new JdbcTemplate(sqlDataSource); List<Map<String, Object>> results = temp.queryForList("SELECT last_name FROM actor"); List<Object[]> params = new ArrayList<Object[]>(); for (Map<String, Object> row : results) { params.add(new Object[]{row.get("last_name"), row.get("actor_id")}); } String sql = "UPDATE actor SET first_name= ? WHERE actor_id=?"; temp.batchUpdate(sql, params) 

In this example, I am trying to update all first names in my table to the last names. My main question is how can I include a parameter for the "SET first_name = ?" as well as the WHERE condition "WHERE actor_id = ?" as well? Is this possible with JdbcTemplate?

1 Answer 1

-1

I think a simple Google search can solve your problem(s). If you just look up JdbcTemplate batchUpdate, it should guide you in the right direction. With that said, have a look at these:

Sign up to request clarification or add additional context in comments.

1 Comment

Google searches can get outdated. Answer the question. If you can't be bothered to, don't bother providing just links.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.