File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Stored procedure & auto commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Stored procedure & auto commit" Watch "Stored procedure & auto commit" New topic

Stored procedure & auto commit

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 782

If I have my SQL code inside a stored proc and I want the store proc to execute within a transaction; does setting the autocommit to false achieve this or do I need to
do a BEGIN TRANSACTION/END TRANSACTION within the stored proc.
Another related question is that I've set the
isolation level to "Serializable" in the connection object. Is this enough to achieve the above ?


Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 567
As long as autocommit is off, then you don't need begin / end transaction in your stored proc.
The database will get your drift and wrap it all in one transaction with your other DB operations.


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Consider Paul's rocket mass heater.
subject: Stored procedure & auto commit
It's not a secret anymore!