Update and Delete Rows with JdbcRowSet Object

By | August 5, 2018

This post talks about Update and Delete Rows with JdbcRowSet Object.Based on the JDBC documentation, a JdbcRowSet object is extended from a ResultSet object and defined to be updatable by default. This means that you can use JdbcRowSet objects to update, delete or insert rows back to target tables in the database server.

In previous post  Insert and Select Rows with JdbcRowSet Objects we already learnt how insert and select records or rows in database.

In this post we will learn how to Update and Delete Rows with JdbcRowSet Objects

Project structure in eclipse:

SQL Query to create employee_table and insert few rows in MySQL (jdbcdb schema)
(Note:Make sure you have created employee_table and inserted few records in jdbcdb database schema)
DB.sql 

After running above db script in your MySQL jdbcdb schema employee_table will have following content.

UpdateRowClientTest.java class to  show update a row using JdbcRowSet

After running UpdateRowClientTest.java program you will look below  output on eclipse console:

Above eclipse console output says employee email is updated whose id is 4
You can query database table to check the same.

DeleteRowClientTest.java class to  show delete a row using JdbcRowSet

After running UpdateRowClientTest.java program you will look below  output on eclipse console:

Above eclipse console output shows all employees info before and after a employee  row deleted from database table.
Let’s query database table to verify the same.

That’s all about this topic Update and Delete Rows with JdbcRowSet Objects
If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *