UPDATE Query

Learn how to update an existing record in the database.

We'll cover the following

JdbcTemplate update() method

The update() method of the JdbcTemplate is used to execute INSERT as well as UPDATE queries. So, to update a record in the table, we will create a method updatePlayer() in the PlayerDao class, which will be similar to the insertPlayer() method. The only difference is in the query, which will change from INSERT to an UPDATE query.

The updatePlayer() method will take a Player object and update the row corresponding to the Id value of the object. As mentioned in the previous lesson, the update() method of the JdbcTemplate returns the number of rows affected by the query.

Get hands-on with 1400+ tech skills courses.