About Question enthuware.ocpjp.v7.2.1196 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ewebxml
Posts: 78
Joined: Sun Jun 30, 2013 10:04 pm
Contact:

About Question enthuware.ocpjp.v7.2.1196 :

Post 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?

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Well, if the table already has rows, then none of the options can be valid.
If you like our products and services, please help us by posting your review here.

leorbarbosa
Posts: 17
Joined: Wed Nov 26, 2014 1:59 pm
Contact:

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

Post by leorbarbosa »

So, 'setAutoCommit(true)' saves all previously pending 'inserts'? (this sounds strange...)

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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)
If you like our products and services, please help us by posting your review here.

krohani
Posts: 31
Joined: Tue Oct 06, 2015 1:57 pm
Contact:

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

Post 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?

admin
Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

lilly.c4488
Posts: 1
Joined: Mon Jul 25, 2016 12:58 am
Contact:

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

Post 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();

Post Reply

Who is online

Users browsing this forum: No registered users and 104 guests