This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Transaction failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Transaction failure" Watch "Transaction failure" New topic

Transaction failure

Santiago Conde

Joined: Nov 09, 2004
Posts: 16

I'm having a curious problem here: if I use con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) and a problem arises during operations, the rollback() method doesn't rollback. Instead of that, if I use con.createStatement(), the rollback works right (con -> a connection).

Using JDBC driver jtds, connecting to a SQLServer. The same issue connecting to a DB2/AS400.

Any ideas?


Dudo, your brain is vanishing like the fog.- Fraggel Rock
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32818

By using the CONCUR_READ_ONLY setting, you are telling the driver that your queries do not update the database. Therefore, the driver thinks there is nothing to roll back.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Santiago Conde

Joined: Nov 09, 2004
Posts: 16
Hi Jeanne

Yes, I noticed that and also tested it with the option 'UPDATABLE': same behavior.

One thing I forgot to tell is that a use SQL strings and the executeQuery()/executeUpdate() methods to issue the commands. It's my understanding that doing so, the second parameter in the createStatament method should be irrelevant since I'm not working with the RecordSet attributes to modify the database records.

Right now I have solved my problem using a default RecordSet and an ArrayList to move back and forward through the data, but I'd like to understand why is this happening.

Take care.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Transaction failure
It's not a secret anymore!