• 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

Can I call a stored proc without wrapping it in a transaction?

 
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Microsoft SQL Server, but this is a general question about calling stored procs via JDBC.

I want to manage transactions within my stored proc (i.e. by placing BEGIN TRAN and COMMIT TRAN around relevant pieces). But whenever I call a stored proc through JDBC it always seems to be wrapped in a transaction - either implicitly with the 'auto-commit' setting turned on, or explicitly using commit().

Is there some way I can call SQL without having it wrapped in a transaction?

David
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Databases have two kinds of statements: DML and DDL. DML is always in some form of transaction. Not a Java issue, just the reality of database architecture. Some databases will let you change the transaction isolation level so that different threads of execution can see each other's interim results, but the transactionality is still in effect - the changed isolation level just means that you don't have all the ACID properties.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, it's usually not a good idea to have a java.sql.Connection's autoCommit property set to true -- that mode is intended for ad hoc SQL console work.
 
David Peterson
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic