This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes transaction when we 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 "transaction when we "select" data from db ?" Watch "transaction when we "select" data from db ?" New topic
Author

transaction when we "select" data from db ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798

Do we need a transaction when we "select" data from db ? The coding is below, though it is hibernate version.

Thanks.

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Depends what you want to do with the data. If you plan on updating the data but there was no transaction, then there would be no guarantee on the data at the point you go to save your records.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3718
    
  61

This may strongly depend on the database. In Oracle, for example, you can start the transaction in serializable mode (or read-only mode for that matter, though JDBC does not directly support read-only transactions) and all your selects will return data as they existed at the time the transaction started. This may be important in regard to the consistency of data being read.

In other databases the transaction (and its isolation level) might affect the results in different ways.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: transaction when we "select" data from db ?
 
It's not a secret anymore!