Hi Amar,
If every connection uses a different username:password to connect to the
database, I don't see how you can share your connections among different
users so I don't see the point of creating a connection pool. In that
case, you might try what Daniel(Kirkedoffer) suggested and keep a
reference to the user-specific connection in each user's Session.
What you get with a connection pool is that you save the time to open
the connection to the database, because you already have them opened. We
found it useful when the network connection time is not too big
otherwise the users won't percive the difference. Tuning the connection
pool (number of opened connections, minimums, maximums, angry DBA admins
:)...) and handling used connections(what do you do when they give you a
used connection back? commit? rollback?) can be tricky so consider
carefully if you want to use one or not, and if you want to develop one
yourself or get one that's already built.
I needed one and I developed it myself, but it was far from being
bullet-proof as I knew that JDBC2.0 will give them to me, and because
I'm using now EJB and most of EJB servers handle this for you so...
I hope this helps,
Dan
PD: IMHO, a connection pool is almost always quite useful. Even though
when you have not too many users, if your operations are fast your users
will notice those extra 1-2 seconds that it takes to open a new
connection every time. If you have lots of users, you should have a pool
with a properly set maximum number of connections, otherwise your DBA
admins will kill you when you choke their toy. In my case, I'm both the
developer and the DBA Admin so I try not to get angry with myself :). If
you have a different user:password combination for every user, then no
pool will help you unless you want to keep a connection open all the
time for every single user of your system, or you want to define a
complicated pool-cache policy... I'd recommend neither one.
"Kirkdorffer, Daniel" wrote:
>
> A new instance of the LoginBean will be created for each session. It would
> be more appropriate for you to maintain your connection pool in another
> class, and for your LoginBean to ask that class object for a new connection.
> You should also consider how best to manage the connection pool so that it
> appropriately recovers from a server shutdown or the like.
>
> Another, simpler, approach would be to have each LoginBean establish and
> retain its own database connection. The price of doing this is really only
> going to be once, at login. We looked at using connection pools, and for a
> small number of connections it really didn't save us much on systems that
> will not need to be scaled up. In fact our DBAs said no to us even using
> connection pools, and here they decide such things. They didn't want a
> bunch of open and unused connections sitting around.
>
> Probably rubs all the connection pool purists out there a little bit the
> wrong way, but hey!
>
> Cheers,
>
> Dan
> --
> Daniel Kirkdorffer
> NACN IS: 425-580-6225
> Sr. Consultant, Syllogistics LLC
> Email: [EMAIL PROTECTED]
> Web: http://www.syllogistics.com/
>
> > ----------
> > From: Nanduri Amarnath[SMTP:[EMAIL PROTECTED]]
> > Reply To: [EMAIL PROTECTED]
> > Sent: Wednesday, September 29, 1999 7:13 AM
> > To: [EMAIL PROTECTED]
> > Subject: Database Connections
> >
> > Hi everybody,
> > I am using a LoginBean as a Session Object in my JSP pages. The
> > LoginBean
> > takes user info and connects to a Database (where it validates the
> > username and
> > password). I am using a ConnectionPool to maintain a pool of connections
> > to a
> > Database. I am creating the ConnectionPool inside the constructor of the
> > LoginBean.
> >
> > My question is... If some 10 clients use my app.. will 10
> > ConnectionPools
> > be created ? If so, how can i overcome this to maintain only a single
> > connection
> > pool and have all my LoginBeans (sessions) access that pool.
> >
> > Forgive me if i am wrong...but i was under the impression that only a
> > single
> > LoginBean will be created on the server and all the JSP requests access
> > that
> > bean. If this is the case, then how can i maintain sessions for all the
> > different users ?
> >
> >
> > In servlets i used the init() method to create my ConnectionPool. Is
> > there
> > anything like this method, that i can use in the JSP to create my
> > ConnectionPool
> > ?
> >
> > Thank you very much for your feedback.
> >
> > Cheers,
> > Amar..
> >
> > [EMAIL PROTECTED]
> >
> > ==========================================================================
> > =
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > FAQs on JSP can be found at:
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> >
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
--
-------------------------------------------
Daniel Lopez Janariz ([EMAIL PROTECTED])
Web Services
Computer Center
Balearic Islands University
-------------------------------------------
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html