How can I use Connection Pool?

Bozidar Dangubic

Additional info:
I am using Oracle 9ias server. I have given max-connections to 50 in data-sources.xml file. And the class i am using is "oracle.jdbc.pool.OracleConnectionCacheImpl". I have also tried with OracleConnectionPoolDataSource class in data-sources.xml. But i feel that connection pool is not utilised, because in the middle of the retrieval, the server hangs as there will no be connections left for opening...
In entity beans, I have created connections in setEntityContext and releasing them in unsetEntityContext...
Do not get the connection in the setEntityContext. Get the connection only when you need it.
If you get the connection in setEntityContext with the pool of 50 connections and you retrieve 50 different entity beans each bean will hang on to the connection and you will hang.
So, get the connection when you need it and release the connection as soon as you have no need for it any longer.
There is no reason to get the connection in setEntityContext.