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.
I'm just wondering, if do we still need to invoke commit even though we only executed a select query (which means no manipulation will happen on database)?
On the other hand, or is it efficient to call commit without doing any manipulation on database?
Deepak Bala wrote:A select query does not need a commit.
You can set a connection to auto commit or set method level transactions or some other form of transaction level management to take care of commits
Largely correct. However, most databases will have to rely on their time out behvaiour to release the resources associated with the transaction if you don't commit or rollback. So if you start one, its a good idea to finish it. Like you said, the best approach for selects is not to use a transaction.