> Problem Description:
>
> The above servlet and its classes work fine for a brief period of
> time.  After
> several requests are handled, the servlet starts to receive a
> DB2.Exception, no
> more handles.
>

Hi David,

    it is important to remember that Servlets live in a multithreaded
environment (unless you implement SingleThread...) and that web apps should
always be run stateless using session objects to store state information
where
needed.

Your connection is probably being overrun with requests. There are several
ways
to go about solving this problem.

1) Connection Pooling

2) Storing the connection in a session object


First solution is more complicated to code but ensures that you never try
and create more connections than your DB can handle.

The second solution is easier but in a high traffic environment can bring
your DB server to its knees and also is more problematic if you are not
using Servlet API 2.0 or higher because I would only recommend this
technique if you can bind to sessions.

In any event having just the one connection for a servlet is not a good idea
because of the problems with multiple hits across it.

An easy way to check that this is correct is to simply implement
SingleThreadModel

ie public class YourHttpServlet extends HttpServlet implements
SingleThreadModel {
}

If resources are being released properly after each DB request and you are
properly
disposing of the connection in the destroy method then you will definitely
need
to try implementing either one of the above solutions OR think of one of
your own.

Hope this helps

Andy Bailey

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to