CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    32

    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

  2. #2
    Join Date
    Nov 2004
    Posts
    32

    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

  3. #3
    Join Date
    Apr 2003
    Location
    Los Angeles area
    Posts
    776

    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.
    "The Chicken and Rice MRE is not a personal lubricant."

  4. #4
    Join Date
    Nov 2004
    Posts
    32

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured