Insert a Row using an updatable ResultSet

By | August 1, 2018

In previous post How to update a Row in a Database Table Using an updatable ResultSet we learnt how to update a record in  database table using  a updatable  ResultSet . In this post we will learn how to Insert a Row using an updatable ResultSet in database table.

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)

After running above db script in your MySQL jdbcdb schema employee_table will have following content. class which is responsible to connect with MySQL database.

Model class Employee .java

Now let’s run our class to insert a row in employee_table 
You can modified this program as per your requirement.

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

Above eclipse console output clearly says that a new employee is created with employee_id 5
If you query database employee_table then you will find one more record is inserted with employee_id 5 as below:

That’s all about  How to insert a Row in a Database Table Using an updatable ResultSet
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 *