How to achieve Connection polling in JDBC

Anand Bhatt

Ranch Hand

Posts: 189

posted 7 years ago

In my app code i am, for each and every method i am taking a Jdbc Connection( defined as a singleton class) using it and at the end of every method i am closing it.
Overall there is lots og conection opening and closing in that file. How can i get rid ofthis frequent opening and closing of connection.

Don't reinvent the wheel. Most application servers provide a mechanism for creating and managing connection pools. In such a scenario, you then request a connection from the data store and it will give you one if its open. Check the documentation for whatever application server you are using to see how to establish connection pools.