William,
thanks. IOt turns out that after looking at my
problem in a little more detail, I figured this must
be the issue. I guess this leads to another question.
Once you destroy a servlet, can you reinitialize it.
If so how?
thanks,
-Amos
--- William Kaufman <[EMAIL PROTECTED]> wrote:
> > This is not really a jdbc issue. What is
> happening is
> > that my code specifies that the conenction to the
> > database is made only during the init of the
> servlet
> > and the conenction is closed after the servlet is
> > destroyed.
>
> Ah, OK. Don't do that.
>
> init() is called exactly once, when the servlet gets
> loaded.
>
> If you want to close and re-allocate the connection,
> do it in your
> doGet()/doPost()/doWhatever() methods (if you've
> overridden those) or in
> your service() method (if you didn't): connect at
> the beginning,
> commit/rollback and close at the end (preferrably in
> a "finally" block, to
> make sure it gets done).
>
> -- Bill K.
>
> > -----Original Message-----
> > From: A.L. [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 07, 2001 10:27 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Servlet/ Database Conenction Persists
> Question
> >
> >
> > This is not really a jdbc issue. What is
> happening is
> > that my code specifies that the conenction to the
> > database is made only during the init of the
> servlet
> > and the conenction is closed after the servlet is
> > destroyed. I think that my problem is that once I
> > destroy the servlet, I can't figure a way to re
> > initialize it. Simply refreshing the servlet page
> > doesn;t seem to work.
> > --- William Kaufman <[EMAIL PROTECTED]> wrote:
> > > > I have developed a servlet web application
> > > which
> > > > connects to a database to retrieve
> information. I
> > > > noticed that if within my servlet I destroy
> the
> > > > connection to the database there is no way to
> > > > reconnect to the database .
> > >
> > > Maybe this is a JSP thing (I'm not too familiar
> with
> > > those), and JSPs have
> > > some weird JDBC cover methods. But you _should_
> be
> > > able to disconnect, by
> > > calling Connection.close(); and to reconnect,
> the
> > > same way you connected the
> > > first time.
> > >
> > > Why can't you reconnect? Are you getting an
> > > exception from
> > > DriverManager.getConnection()?
> > >
> > > > Is keeping the persistent connection to the
> > > database
> > > > a heavy burden on tomcat?
> > >
> > > Persistent connections aren't a burden on
> Tomcat,
> > > but might be on your
> > > database, especially if the modifications aren't
> > > committed immediately. You
> > > should always try to close connections (and
> other
> > > resources) if you don't
> > > think you'll be using it again in a few seconds.
> > >
> > > > I don't believe my question pertains
> > > specifically to
> > > > Tomcat, so I was wondering whether or not any
> of
> > > you
> > > > knew where there are list servers which deal
> with
> > > > servlets in general.
> > >
> > > This mailing list is fine for general servlet
> > > questions. But this seems to
> > > be a JDBC question,...
> > >
> > > -- Bill
> K.
> > >
> > > > -----Original Message-----
> > > > From: A.L. [mailto:[EMAIL PROTECTED]]
> > > > Sent: Tuesday, August 07, 2001 9:07 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Servlet/ Database Conenction Persists
> > > Question
> > > >
> > > >
> > > > I have developed a servlet web application
> > > which
> > > > connects to a database to retrieve
> information. I
> > > > noticed that if within my servlet I destroy
> the
> > > > connection to the database there is no way to
> > > > reconnect to the database . In other words I
> need
> > > to
> > > > keep my connection to the database at all
> times
> > > that
> > > > tomcat is up. My questions include:
> > > >
> > > > Is this correct that there is no way to
> reconnect
> > > to
> > > > the database? If this is not correct, how
> does
> > > one
> > > > reconnect, and or reinitialize the servlet?
> > > > Is keeping the persistent connection to the
> > > database
> > > > a heavy burden on tomcat? In other words, is
> it
> > > o.k.
> > > > to design an application which never releases
> its
> > > > conenction to the database?
> > > >
> > > >
> > > > I don't believe my question pertains
> > > specifically to
> > > > Tomcat, so I was wondering whether or not any
> of
> > > you
> > > > knew where there are list servers which deal
> with
> > > > servlets in general.
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Make international calls for as low as
> $.04/minute
> > > with
> > > > Yahoo! Messenger
> > > > http://phonecard.yahoo.com/
> > > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with
> > Yahoo! Messenger
> > http://phonecard.yahoo.com/
> >
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/