tags:

views:

78

answers:

3

Hii All, I want to implement connection pooling in my web application.please suugest how can i implement that.

+1  A: 

I'd say that you have two problems:

  • You don't know whether you need connection pooling or not

and

  • If you find it's needed, you don't know how to implement it.

I'd initially work on the assumption that you DON'T need it, reusing connections is a (possibly premature) optimisation.

However, if you find that you really do need it, then how you do it will depend on the nature of your application-server.

  • If your application is "in-process" with Apache, you really have no option other than one-connection-per-process (or thread)
  • If your app is "out of process", e.g. connecting to Tomcat via mod_jk, then you can do what you like within the app server (Tomcat) which may include pooling connections to be used across multiple threads as appropriate.

Compelling reasons for using a new connection each time are:

  • No unwanted side effects from old connection state left by previous requests
  • You only connect when needed - less risk of blowing your database connections
  • Predictable performance - you can measure the time taken for the request, including creating the connection

The only compelling reason for reusing connections is the connection overhead time itself.

Some databases are relatively slow creating connections (Oracle) - others are much faster (MySQL). Some databases can be tuned to keep a pool of threads internally which they reuse (MySQL) which makes connecting even faster.

MarkR
A: 

http://commons.apache.org/dbcp/

SUMMARY:There are several Database Connection Pools already available, both within Jakarta products and elsewhere. This Commons package provides an opportunity to coordinate the efforts required to create and maintain an efficient, feature-rich package under the ASF license.

adatapost
A: 

While i do not have a definitive answer (and am also looking it), i can suggest the following (for a perl backend):

Hartmut Behrens