From: Danny Rubis
> I suggest that you *not* hold the connection at all.
> Just get it when you need it. If you are worried
> about performance, connection pools will help.
>
> I, for one, never hold a connection. It's too
> problematic. I can name a half dozen things
> that can go wrong.
> Henning Brune wrote:
> > in our servlet application we face the problem of loosing
> > the database connection all couple of days.
> >
> > Now we want to restart it every 24 hours. My first idea
> > is to use a thread that sleeps this long time an then does
> > the restart. Are there any drawbacks with this solution ?
I agree with Danny. When I first read Henning's message I
assumed that he was using a connection pool, but on re-reading
perhaps that is not the case.
If you *are* using a connection pool, throwing away connections
every day or so might well be a good idea in any case!
It may well be that the database is written assuming shorter
connection lifetimes, and may behave poorly in dealing with very
long lived connections. Put differently, I'm confident that any
good database will work well connections that last up to a day,
but I'm *not* confident that every revision of any database you
might end up using is as throughly tested and reliable with the
longer lived connections.
The cost of dropping/reconnecting once per day is insubstantial,
and may well yield better/safer operation. Better yet, if there
*is* a problem you might never need know :).
Given that you are using a connection pool, you don't really need
a seperate thread. When you grab a connection from the pool just
check it's age. If it's too old (over a day perhaps) then close
it and grab the next connection from the pool.
--
Preston L. Bannister
[EMAIL PROTECTED]
http://members.home.com/preston
pbannister via Yahoo! Messenger
___________________________________________________________________________
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