Learn how to delete row using ResultSet. We are also used ResultSet object with update capability for delete rows from database tables. The following step are use:
1. Create a database connection object.
2. Create a statement object with ResultSet.CONCUR_UPDATABLE concurrency type.
3. Create a SQL select query.
4. Execute query using executeQuery() method on the created statement object to return ResultSet object on the table.
5. Call ResultSet methods like next(), absolute(), last() etc for cursor move.
6. Finally call deleteRow() ResultSet method for delete the current row form the table of the ResultSet object.
In this example we are deleting row that have user_id == 1.
Now we will run this example with the help of eclipse IDE and see the output.
The database table output before run the example is:
The eclipse console output is:
The database table output after run example is:
Posted on: October 23, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles