• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transaction failure

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

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?

Thanks.
Santi
 
author & internet detective
Posts: 41878
909
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
Santiago,
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.
 
Santiago Conde
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Santi
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic