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
init()
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?