destroy servlet database connection
hello guys
i am facing a problem regarding one of my servlet
i use init() method to initialize the connection to the database and after that i use destroy method to disconnect from the database.
like this
destroy() {
try {
connection.close();
}
catch (Exception e){
out.println(e);
}
but the problem is after a couple of hours and i think when the destroy method executed any request to the database failed.
this is the exception
java.sql.SQLException: No operations allowed after connection closed.
now i dont really know the solution for this matter but if there is a way to solve it please dont hasitate to response
thanks
Re: destroy servlet database connection
can any one help
the second thing is the method destroy() shutdown all my connection to the server or the database so in case i request data from the database in the future should the database response.
thanks alot
Re: destroy servlet database connection
Most likely the database is closing the connection due to inactivity well before your container unloads your servlet and calls destroy. This would be a timeout setting on the database config files. You should perhaps make database connections on a per request basis if there really is hours between requests or look into connection pooling support for your servlet container.
Re: destroy servlet database connection
thank you joe
now what is connection pooling ? and how can i get one?
until now i cant connect to the database
and i get this message
unavailable invoker
strange