Page 1 of 1

About Question enthuware.ocpjp.v7.2.1196 :

Posted: Wed Apr 30, 2014 2:13 pm
by ewebxml
For this question,

"Assuming that the table student2 does not have any row, how many rows will be present in this table after the following code is executed? "


"Assuming that the table student2 does not have any row"

does this statement have any relevance on the choice to select?

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

Posted: Thu May 01, 2014 1:21 am
by admin
Well, if the table already has rows, then none of the options can be valid.

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

Posted: Sun Nov 30, 2014 8:49 am
by leorbarbosa
So, 'setAutoCommit(true)' saves all previously pending 'inserts'? (this sounds strange...)

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

Posted: Sun Nov 30, 2014 10:21 pm
by admin
leorbarbosa wrote:So, 'setAutoCommit(true)' saves all previously pending 'inserts'? (this sounds strange...)
Yes, but only if the auto commit mode was false before. You should go through this JavaDoc description: http://docs.oracle.com/javase/7/docs/ap ... t(boolean)

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

Posted: Sun Jan 31, 2016 7:31 pm
by krohani
I am having some issues with MySQL otherwise I would try this myself but here is my question....

Does calling conn.rollback() (w/o a savepoint passed in) roll all statements in the transaction back or does it rollback statements up until it encounters and unnamed savepoint?

pseudocode:
autocommit(off)
stmt.executeupdate(1)
savepoint unnamed
stmt.executeupdate(2)
savepoint named
rollback - no savepoint given
commit

Does this sequence rollback back to the unnamed savepoint and then commit update1 or does it rollback everything and commit nothing?

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

Posted: Sun Jan 31, 2016 10:54 pm
by admin
A call to rollback() will roll back all the changes done in this transaction (irrespective of any save points).
A call to rollback(SavePoint) will roll back only those changes made after the given save point.
So in your example everything (after setting autocommit(off) ) will be rolled back.
HTH,
Paul.

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

Posted: Mon Jul 25, 2016 1:05 am
by lilly.c4488
I agree with rollback and savepoint logic for 2 rows.

But database will not be updated unless:
Statement stmt = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

NOT Statement stmt = c.createStatement();