Question: What is the best way to manage a database connection in a Java servlet?

Currently, I simply open a connection in the `init()` function, and then close it in `destroy()`. 

However, I am concerned that "permanently" holding onto a database connection could be a bad thing. 

Is this the correct way to handle this? If not, what are some better options?

edit: to give a bit more clarification: I have tried simply opening/closing a new connection for each request, but with testing I've seen performance issues due to creating too many connections.

Is there any value in sharing a connection over multiple requests? The requests for this application are almost all "read-only" and come fairly rapidly (although the data requested is fairly small).

Answer: 
I'd use [Commons DBCP](http://commons.apache.org/dbcp/). It's an Apache project that manages the connection pool for you.

You'd just get your connection in your doGet or doPost run your query and then close the connection in a finally block. (con.close() just returns it to the pool, it doesn't actually close it).

DBCP can manage connection timeouts and recover from them. The way you are currently doing things if your database goes down for any period of time you'll have to restart your application.
Usually you will find that opening connections per request is easier to manage. That means in the doPost() or the doGet() method of your servlet.

Opening it in the init() makes it available to all requests and what happens when you have concurrent requests?