Author | Message |
---|---|
dguhath
Posts: 61
|
Posted 08:27 Dec 01, 2014 |
If I plan to create a connection pool in my application what will be the ideal place to initialize and release the connections? |
cysun
Posts: 2935
|
Posted 08:46 Dec 01, 2014 |
Tomcat comes with its own connection pooling library. If the server is under your control, I'd say the easiest way is to configure it as a Tomcat resource so you don't need to worry about it in your application. See http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Getting_the_actual_JDBC_connection. If your application wants to maintain its own connection pool, you can use a ServletContextListener (initialize it in contextInitialized() and release it in contextDestroyed()) or a just a loadOnStartup servlet (initialize it in init() and release it in destroy()). |
cysun
Posts: 2935
|
Posted 08:58 Dec 01, 2014 |
Now that I think of it, you can probably configure it as a resource in the web.xml of your application too. |
dguhath
Posts: 61
|
Posted 09:04 Dec 01, 2014 |
Thanks a lot Dr.Sun. |