Page 1 of 1

About Question enthuware.ocpjp.v7.2.1686 :

Posted: Mon May 13, 2013 12:34 pm
by renatumb
ResultSet is a read only object. You cannot change (i.e. update) anything in the database using a ResultSet object.
Do you mean the resultset that was created in the question or EVERY/ANY ResultSets ?

I dont know if it is a good practice, but it's possible use a ResultSet to change values in a DB:
To insert:

Code: Select all

ResultSet rs = connection.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE).executeQuery(sql);

rs.moveToInsertRow();
rs.updateObject(column,value);
rs.insertRow();
Update:

Code: Select all

rs.absolute(lineOfTable);
rs.updateObject(column,value);
rs.updateRow();
Delete:

Code: Select all

rs.absolute(lineOfTable);
rs.deleteRow();

Re: About Question enthuware.ocpjp.v7.2.1686 :

Posted: Wed May 15, 2013 6:41 am
by admin
You are right. The answer is correct but the explanation is not. This has now been fixed.

thank you for your feedback!
Paul.