tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: OFF TOPIC: Some pretty basic Tomcat Connection Pooling Questions????
Date Wed, 08 Sep 2004 13:57:49 GMT

Hi,
Your application is not started when you log into it.  It's started when
the server is started.  That's when a connection pool should be created.

You don't hold the connection as long as the user is logged in.  You
just use the connection to authenticate the user and then release the
connection back to the pool.

Most books in this area are user-friendly, as they are target at novice
programmers.  You don't even have to buy a book, either.  Take a look at
something like
http://www.javaperformancetuning.com/tips/jdbcconnpool.shtml, which has
many of these principles explained.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Michael McQuade [mailto:m.mcquade@sympatico.ca]
>Sent: Wednesday, September 08, 2004 9:42 AM
>To: Tomcat Users List
>Subject: Re:OFF TOPIC: Some pretty basic Tomcat Connection Pooling
>Questions????
>
>Ok Yoav,  so as I understand it,   I open up my application say in the
>morning,  by logging in my company......  I do not close the connection
to
>my database....  Now any number of users can log into it,  as they
login
>(servlet) I do not need to open and close my database to update
it??????
>this user may sit all day logged in,     you say the connection needs
to be
>returned to the pool????? Throughout the day, that user may access the
>database at anytime.....
>Im really sorry,   this is all new to me and Im trying to get a handle
on
>it
>in plain English from people who are experienced,  not all the
technical
>terms you get from a manual..... Im desperate for help and fast running
out
>of time to get it...... I have put Connection Pooling into Tomcat thru
the
>Server.xml and Web.xml,   per the examples from Tomcat documentation,
but
>HOW  do I know it is really turned on and working????
>Currently my application does a Connect and Disconnect each time a
>Program/servlet is executed......  But this isnt working,  I get an
08002
>(connection name in use) SqlState the second time I try to connect.....
>When I remove the Connect/Disconnect from all my other servlets,   I
get an
>SqlState 08000 (connection exception) the first time I try to access
the
>database....
>
>Please forgive me for being so stupid, Im just looking for someone that
can
>give me some guidance here...... If anyone from the User group would be
>willing to talk in private,  so as not to disturb others in the group
with
>my asking for help, I would welcome that also....
>
>Mike
>m.mcquade@sympatico.ca
>905-985-3438
>
>
>----- Original Message -----
>From: "Shapira, Yoav" <Yoav.Shapira@mpi.com>
>To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>Sent: Wednesday, September 08, 2004 8:44 AM
>Subject: RE: Some pretty basic Tomcat Connection Pooling Questions????
>
>
>
>Hi,
>You might want to get a book on good Java design practices.  The basic
>ideas are there:
>- Hold the connection for as little a time as possible.  That is, get
it
>from the pool, use it, and return it to the pool as soon as possible.
>- That means you don't get the connection in a servlet init() method
and
>return it in a destroy() method.  That's too long a time to hold
>connections usually.
>- Always return connections to the pool.  Typically, this is done in
the
>finally clause of a try/catch block to ensure it is executed even if
the
>JDBC operation fails.
>- You create your pool once, preferably when the app starts up, and you
>close the pool itself once, preferably when the app shuts down.  A
>ServletContextListener is good for this purpose.  Make sure you close
>the pool.
>- Servlets and other classes use the pool as needed.  You don't have to
>use a one connection per servlet design (in fact those usually don't
>work in the real world).
>
>In the future, please mark non-Tomcat questions with [OFF-TOPIC] in the
>subject line.  And again, consider getting a Java design practices
book:
>practically all of them have a chapter on JDBC connection pooling with
>the above suggestions.
>
>Yoav Shapira
>Millennium Research Informatics
>
>
>>-----Original Message-----
>>From: Michael McQuade [mailto:m.mcquade@sympatico.ca]
>>Sent: Tuesday, September 07, 2004 9:06 PM
>>To: Tomcat Users List
>>Subject: Some pretty basic Tomcat Connection Pooling Questions????
>>
>>Sorry folks,   this is a REAL Newbie to Tomcat/Java.....  Im trying to
>>understand Connection Pooling as it seems I will need this in my
>webapp....
>>Please dont laugh too hard at me ok....
>>
>>When doing connection Pooling,    do you do an Open and close of your
>>database for every Java class (servlet) you execute?
>>
>>Or
>>
>>Do you do a one time Open of your database at the first login?
>>
>>Or
>>
>>Do you just do an Open Database and NOT a CLOSE database for each Java
>>Class (servlet)?
>>
>>I know this sounds stupid,   but Im currently NOT using Connection
>Pooling,
>>and when I  go into my first Java class (servlet),  I can OPEN/UPDATE
>all
>>successfully,   but when I do a Disconnect I get an SQLSTATE = 08003
>>(connection does not exist)
>>I then try and go into my next Java Class  (servlet) and right away,
>on
>>my OPEN, I get SQLSTATE = 08002 (connection name in use)
>>
>>It will never allow to access my database again, I have to go back to
>>Application Manager,  Stop and then Start the application,   go back
>into
>>it,  and I get my one connection again,  but just the one.....
>>
>>Thanks Mike
>
>
>
>This e-mail, including any attachments, is a confidential business
>communication, and may contain information that is confidential,
>proprietary
>and/or privileged.  This e-mail is intended only for the individual(s)
to
>whom it is addressed, and may not be saved, copied, printed, disclosed
or
>used by anyone else.  If you are not the(an) intended recipient, please
>immediately delete this e-mail from your computer system and notify the
>sender.  Thank you.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message