File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes implementing connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "implementing connection pool" Watch "implementing connection pool" New topic
Author

implementing connection pool

Pushker Chaubey
Ranch Hand

Joined: Dec 06, 2006
Posts: 53
Hi Experts,

I am trying to implement connection pooling using ConnectionPoolDatasource in a simple java application. I am following these steps -

1) Create a PoolManager class with method to getConnection(). This class implements ConnectionEventListener
2) Create instance of ConnectionPoolDataSource (actually the implementation class provided by vendor)
3) Use getPooledConnection() calls on connectionpooldatasource to get ready with 10 pooled connections in a List
4) register PoolManager as connectionEventlistener to all these pooled connections
5) on Call to PoolManager.getConnection(), take one readymade pooledConnection from list and call getConnection() to obtain connection handle and return
6) In listener method for connectionClosed() get the event source (which is the corresonding PooledConnection) and add it back to list of available pooled connection

This seems to work. But I am not sure whether this is the right way to implement.
Please guide me on this.

Thanks
Pushker Chaubey
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

Pushker,
Very few people have implemented a connection pool. You might try seeing if dbcp does what you need. Or at least compare your algorithm.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: implementing connection pool
 
Similar Threads
ConnectionPoolDataSource
Connection Pooling
JDBC MSSQL 2000 connection pool manager
Help! Getting IOException and Communication Link error with DB
URGENT: Help Correctly Using ConnectionPoolDataSource in Servlet!