This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connection Pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection Pooling" Watch "Connection Pooling" New topic

Connection Pooling

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
I have a query regarding connection pooling. Am using a data source for the EJB interface. And it uses 50 connections minimum. While the running it reuses the connection (as per pooling technique) but in every transaction some data’s were updated on the database. How come the new data will reflect on the interface application with old connection object.

Whether we need to refresh the database everytime before the transaction starts
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30130

When you close the connection, it commits (updates the database) and returns to the pool for another transaction. There isn't overlap between multiple requests. Everytime you request a connection from the pool, you start out clean.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492

So by default when I close the connection it commits the database. No need to call commit from java side
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Its uncharacteristic behaviour of the Driver which we cannot rely on. However I find Its true that it commits any un-rollbacked transactions when you close the connection.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Connection Pooling
Similar Threads
what are the all advantages of obtaning datasources via JNDI that is configured in J2ee server?
how reliable JDBC Transaction?
Reading / Writing in to table
Tomcat Performance