>> " I restart the servlet the connections seem not to close"
>> How do you restart ?
[quoted text clipped - 12 lines]
> Add some logging statements so you know if/when your code is being
> executed.
Ah yes, that is indeed the case, the VM is not exiting, it's just Tomcat
reloading the context, good one, thanks G and Murray!
Would either of you happen to know if there is an event that occurs when
the servlet is unloaded that I could use to trigger the disconnect
thread? I read through the API text but could not find anything related
to this.
Thanks very much, Jonck
G - 23 Nov 2004 21:54 GMT
Try to implement the destroy method of you servlet.
From J2EE doc : javax.servlet.GenericServlet.destroy()
void destroy()
Called by the servlet container to indicate to a servlet
that the servlet is being taken out of service.
You just have to hope that tomcat call it when switching of servlets.
You can also implement the Object.finalize() system ...
>>> " I restart the servlet the connections seem not to close"
>>> How do you restart ?
[quoted text clipped - 21 lines]
>
> Thanks very much, Jonck
Murray - 24 Nov 2004 01:13 GMT
> Ah yes, that is indeed the case, the VM is not exiting, it's just Tomcat
> reloading the context, good one, thanks G and Murray!
[quoted text clipped - 4 lines]
>
> Thanks very much, Jonck
You can do as G suggested, though preferably the destroy() option.
Have you considered using an existing connection pool library like Commons
DBCP? You configure these as a DataSource in Tomcat's server.xml, and you
don't need to worry about closing connection etc. It's all done for you.
Unless you have very specific requirements, I don't see why you'd want to
reinvent the wheel ...
Jonck - 24 Nov 2004 14:10 GMT
> You can do as G suggested, though preferably the destroy() option.
>
[quoted text clipped - 3 lines]
> all done for you. Unless you have very specific requirements, I don't
> see why you'd want to reinvent the wheel ...
Actually I did try to use an existing library some time ago, but I found
the documentation lacking and was having a hard time setting it up and
getting it all to work. Therefore I just went ahead and coded my own. It
was a good and fun exercise in thread programming, I think I learned a
lot while coding it. But generally speaking you are certainly right, no
use reinventing the wheel.