This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes JDBC performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JDBC performance" Watch "JDBC performance" New topic

JDBC performance

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776

Is it worth it to setAutoCommit off when I'm just doing a query ?


Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

If you have a series of statements to be executed then it is worth to setAutoCopmmit to off.. Otherwise each statement will be executed as a separate Tx.

Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
But execution of the setAutoCommit depends on the underlying driver classes used also...Some of the drivers just ignore the statement.

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 776

Thanks for replying. I am using Oracle 8 thin driver and found this great resource n
benchmark results testing oracle drivers using setAutoCommit off and on. Interesting read.
Roger Thornhill

Joined: May 15, 2002
Posts: 25
In my opinion, you should almost never auto-commit. Implicit execution is generally bad, because it brings with it baggage that you don't often need. Auto-commit is safe for people unfamiliar with databases. But, for those who are comfortable with the basics, it really makes sense to commit explicitly and to perhaps commit sparingly (at some higher logical level).
For example, suppose you want to do an all-or-nothing insert of 100 rows. If one row fails, none of the other rows should be inserted. In that case, you should insert each of the rows without committing and then do the commit at the end. Not only will your batch processing work the way you want it to, but you will get much better performance.
I agree. Here's the link:
subject: JDBC performance
It's not a secret anymore!