• 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

Transactions!

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as per jdbc spec 3.0 a transaction for a jdbc driver is a single sql statement. but what if one wants application level transaction, i.e suppose i want:

transaction begin:
select a
select b
update c
update d
delete e
transaction end.

i want to create such transactions which span beyond a single sql statement, i.e are a combination of multiple sql statements. i want to implement such transactions in servlets. i take a connection from a connection pool via DataSource object(on weblogic server). then should i set auto commit to false, carry out the sql statements, and commit. is this the right approach or is it that in weblogic, every single connection from the connection pool forms a single transaction?
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kriti,

What you describe is the correct way to perform a mulit-statement transaction in JDBC. I don't know about Weblogic ... perhaps one for the Weblogic forum?

I expect that the issue of how you go about committing would depend on whether your transaction is distributed, e.g. whether you're using full J2EE with container managed persistence and so on.

I'm no expert on J2EE, but if you're just using good ole J2SE under Weblogic then your approach is fine.

Regards

Jules
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kirti,

What you have specified is one way of handling transaction. If you don't need distributed transactions, you can manage with con.setAutoCommit(false),
con.rollback() & con.commit(). Only if you need distributed transactions you should worry about using JTA.
reply
    Bookmark Topic Watch Topic
  • New Topic