Sunday, 24 April 2016

Scenario (JDBC 2.0) : How to insert and delete a row programmatically ?


To insert / delete row, make sure the resultset is updatable.

1. Move the cursor to the specific position
rs.moveToCurrentRow();

2. Set value for each column
rs.moveToInsertRow() // to set up for insert
rs.updateString("col1" "strvalue");
rs.updateInt("col2", 5);
...

3. Call inserRow() method to finish the row insert process
rs.insertRow();

4. To delete a row, move to the specific position and call deleteRow() method
rs.absolute(5);
rs.deleteRow();   // delete row 5

5. To see the changes call refreshRow()

rs.refreshRow();

No comments:

Post a Comment

Note: only a member of this blog may post a comment.