eric chacon wrote:

> It is my understanding that each user has a thread, and unless you
> synchonize your servlet methods, each user who is in your servlet will use
> the same JDBC connection.
>
> If you created a connection inside you doGet() method, then you would have 1
> connection per thread.

But this could cause a memory problem, when some user calls this Servlet very
often, and you had no limit for your connections to the Database.
So better use a ConnectionPool.

Greetings,
Michael


>
>
> Whether this works correctly, depends on your JDBC driver, database, etc,
> but I wouldn't suggest you rely on that (and no matter what, it's going to
> be slow).
>
> Typically, a pool of connections is used. Tomcat does not have connection
> pooling built in, but you can download several open-source solutions.
>
> If you're running Tomcat with a J2EE EJB server such as JBoss, then
> connection pooling is part of *that* package.
>
> Hope this helps,
>
> E.
>
> >From: "Gerry Duhig" Reply-To: [EMAIL PROTECTED] To: Subject:
> >Servlets & threads Date: Tue, 8 May 2001 20:55:23 +0100
> >
> >I have written a Java servlet that seems to work quite well but I am
> >confused about the exact context in which it runs.
> >
> >At initialisation it creates a JDBC connection and uses that to connect to
> >a remote Oracle Database on each activation of the servlet. The connection
> >remains open until the servlet closes down.
> >
> >I can see that JServ and Tomcat (I am experimenting with both) create
> >multiple threads, so presumably my servlet can handle multiple simultaneous
> >requests? But what about that one JDBC connection.
> >
> >Is there one per thread?
> >
> >Is there protection so that only one thread can use the connection at a
> >time?
> >
> >Or should I have created some protection to prevent clashes?
> >
> >Its very unclear and I'd appreciate a few clues as to the real situation.
> >
> >Regards
> >
> >Gerry
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com

--
__

Reply via email to