At 10:41 AM -0400 7/20/99, Joe Yandle wrote:
>I had a similar problem on linux / apache-1.3.6 / JServ-1.0 /
>mysql-jdbc-1.0.  When a servlet stayed loaded for a few days, the
>Connection would get stale and I'd get a nasty IOException when the
>connection was used.
>
>I solved it by having my Database class implement runnable, and whenever
>my servlets would instantiate a Database object they would also create a
>thread with that object and call start().  All the run() method did was
>sleep for an hour and then recreate the connection.
>
>
>Joe Yandle
>Internet Programmer
>Westlake Consulting Group

I'd wondered how people handle that, but I guess I still do. Do you then
synchronize your db access, so that your sleepy thread doesn't come and
tear down the connection and rebuild it just as someone wants to (or is)
using it?

More generally, the db could just go down for a bit.

Wouldn't it be better to catch the exception and then try to rebuild the
connection in the catch block? How you loop back from the catch to the try
is a different question and harder to do in a pretty way.

Jeff

-------------------------------------------------------------------------
   Jeff Abrahamson      <http://www.purple.com/jeff>
   [EMAIL PROTECTED]       BeOS, unix, MacOS Development





--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to