Hi Steffy,
With regard to your questions:
how to add a connection to the pool?
...
and what should we code to create the pool?
There are many, third-party connection pools available -- one of which is the one that John has said he is using, from the Apache group's
Jakarta project:
http://jakarta.apache.org And then again, you can always write your own (as we have done at my place of work).
Naturally, each of the implementations will have similarities and differences between them. We wrote our own mainly due to historical circumstances -- not necessarily because it was more appropriate for our application (but that's another story ;-)
You don't mention whether you are using a third-party connection pool or one that you have developed yourself. I assume it is one you have developed yourself, due to the questions you are asking -- since a third-party implementation should have documentation that answers your questions.
In my opinion -- assuming you are writing your own connection pool -- it is probably better to use a third-party implementation, since it is probably going to be better than something you would do (unless you are in the business of making such utilities, of-course ;-), and there are enough of them, that there is a good chance that you will find one that is appropriate for your needs.
By the way, if you are interested in a connection pool as part of some application you are developing, you are aware that most application servers today do include their own connection pool implementations. So if you are already using an application server, I suggest that you investigate the possibility of utilizing its connection pool (if you haven't done so already).
I hope this has helped to answer your questions.
Good Luck,
Avi.