aspose file tools*
The moose likes JDBC and the fly likes Connection Pool Implementation ... ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection Pool Implementation ... ?" Watch "Connection Pool Implementation ... ?" New topic
Author

Connection Pool Implementation ... ?

Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
What is the logic behind connection pooling? How it is implemented? I am looking for some details at the design as well as implementation level. Any tips or links will help.


SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

Vijay,
Javaworld has a good article about connection pooling.


[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
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Thanks Jeanne Boyarsky, I am already aware of connection pooling and have used it in some projects, but recently in one of the interviews the interviewer asked me how to implement the connection pooling, if I have to write the customized connection pool for some application. So I was more interested in writing a customized connection pool application.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
As you know already that in Connection Pooling we have the pool of connections made. Different users use the connection and then give it back to the client. So to develope your own connection pool you will make a connection manager class as singlton and use any Collection object to store the connections.

You will define getConnection,releaseConnection methods in that class. which will give the connection from the pool and take back the connection and insert into the pool.

Major issue to consider in this regard is that you should implement your class as thread safe. If different users request for a connection at the same time and pool is empty then users should wait until a connection is released by another users.

You will define how many connections will you provide and there are different approaches in this regard. You can initialize all the required connections and store then in pool or you will initialize connection on demand.
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Thanks Ali Gohar, it is a real nice explanation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Pool Implementation ... ?