Insert and Select Rows with JdbcRowSet Objects

By | August 4, 2018

This post talks about Insert and Select Rows with JdbcRowSet Objects.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 this post we will learn how to Insert and Select 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.

 

ClientTest.java class to show how to Insert and Select Rows with JdbcRowSet Objects

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

Above output shows initially we read  all the rows from database by calling showEmployeesInfo method after that we inserted a row with primary key 5 

If you query employee_table you will see one row is inserted with primary key 5

That’s all about this topic Insert and Select Rows with JdbcRowSet Objects

You May Also Like:

Transaction basic concept
JDBC transaction management example
Update and Delete Rows with JdbcRowSet Objects
Jdbc RowSetListener example

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 *