This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Sybex OCP 17 Study Guide, Chapter 15 page 908 -- JDBC transaction edge cases

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Review question 21 for chapter 15 has a JDBC connection with auto-commit set to false. In one scenario, the auto-commit is set back to true, which according to the "Edge Cases" blurb on page 894, will cause an immediate commit. The answer key calls this out correctly (answer B)

In the second scenario, the change of auto-commit to true is commented out. According to the same blurb, "... if you have autocommit set to false and close your connection without rolling back or committing your changes ... the behavior is undefined. It may commit or roll back ..." The answer key is consistent with it definitely rolling back (answer D).  

It seems to me the answer should be B and (D or E). Either that or the Edge Case blurb is wrong on this point.
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greg,
That edge case is about uncertainty in the real world to warn anyone using JDBC and autocommit in real code. However, it doesn't conflict with question 21. Those answers say "will". And the edge case says the behavior won't be deterministic. Which wouldn't match any of the answers and therefore you can assume the straightforward case.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne,

I may be reading that wrong, but it seems like you are arguing that the answer to this question should be B only. That is, if auto-commit is off and then turned on, then any uncommitted changes are immediately committed, so the table ends up with one row (answer B), but if auto-commit is not turned back on, and no commit or rollback is performed before the connection is closed, then the database state is undefined. That would make D incorrect, since it says the table "will" remain empty after the code runs. E is also incorrect because it says the table "will" contain one row. If either of these statements said "might", then it would be right, but they both say "will". The question says to pick two answers, and the answer key says those are B and D. I can't see how D is right, but E is wrong here.

Now, I'm guessing that most drivers are going to roll-back in this case, so D will usually be correct, but according to the text, that's not always going to be the case.
 
Jeanne Boyarsky
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. I'll bite that the language is sloppy and add it to our list of things that could be clearer.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I'm still not following here. It doesn't seem like the wording is sloppy, but just that the answer key is wrong. You said the behavior won't be deterministic ... I'm with you on that. It doesn't match any of the answers ... yes that's right. It's non-deterministic so it will either commit the insert or roll it back, but there's no way to tell which. One scenario would make the table have one row, and the other would leave the table empty. We're still on the same page up to there. However, "assume the straightforward case," loses me. What is the straightforward case? The answer key says, "D. The table will remain empty," which as far as I can tell isn't any more straightforward than, "E. The table will have one row."

I feel like you flipped a coin and asked whether it came up heads or tails, and because it can't be determined that means the answer is heads. I'm sure I'm missing something, but I just can't figure out what.
 
Jeanne Boyarsky
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I meant the language is sloppy about exactly what is deterministic.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic