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();
What is JDBC?
JDBC may stand for Java Database Connectivity. It is also a trade mark. JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a different database engine and to write to a single API. JDBC allows you to write database applications in Java without having to concern yourself with the underlying details of a particular database.
No comments:
Post a Comment