Two Laptop Bag
The moose likes JDBC and Relational Databases and the fly likes Connection Pooling 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 "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
author & internet detective

Joined: May 26, 2003
Posts: 33102

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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.
I agree. Here's the link:
subject: Connection Pooling
It's not a secret anymore!