DEVFYI - Developer Resource - FYI

How to insert and delete a row programmatically? (new feature in JDBC 2.0)

JDBC Interview Questions and Answers


(Continued from previous question...)

How to insert and delete a row programmatically? (new feature in JDBC 2.0)

Make sure the resultset is updatable.

1. move the cursor to the specific position.

   uprs.moveToCurrentRow(); 

2. set value for each column.

   uprs.moveToInsertRow();//to set up for insert
   uprs.updateString("col1" "strvalue");
   uprs.updateInt("col2", 5);
   ...

3. call inserRow() method to finish 
the row insert process.

   uprs.insertRow();

To delete a row: move to the specific
 position and call deleteRow() method:

   uprs.absolute(5);
   uprs.deleteRow();//delete row 5 

To see the changes call refreshRow();

   uprs.refreshRow();

(Continued on next question...)

Other Interview Questions