• 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

Continuing a transaction after deadlock

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a transaction which performs multiple database operations - say update1, update2 and update3. The operation update2 is failing occasionally because of a deadlock in Oracle. The exception is as below.

Caused by:
java.sql.BatchUpdateException: ORA-00060: deadlock detected while waiting for resource
ractBatcher.executeBatch(AbstractBatcher.java:242)


I want to catch this exception and retry the update2 operation again if this happens. Will this work or will I have to retry the whole transaction starting from update1 again?

Thanks,
Sandhya
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the Java Transaction API and hand-written code to manage the transaction?

Which Java application server are you using?

What type of JDBC driver are you using?
 
Sandhya Narayanan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No,I'm using declarative transaction handling in Spring using JPATransactionManager. Hibernate is the JPA provider. The application server is WebSphere 6.1. The JDBC driver is Oracle thin driver (type 4)
[ December 13, 2008: Message edited by: Sandhya Narayanan ]
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you place the transaction boundaries before update1 and after update 3, you should be able to catch the exception at update 2 and keep trying update2 until it succeeds. The transaction will not fail if you code the exception handling properly. Code something like after three tries and it still had not succeeded, then abort the transaction and rollback whatever update1 did.
 
reply
    Bookmark Topic Watch Topic
  • New Topic