Thanks Chris,

"If you are going to be running several queries in a row, you should
definitely re-use a connection that you already have, instead of
returning the connection to the pool after every query and then getting
another one for the next."

This is what I plan to do. I have multiple statement from one connection,
and one prepared statement may execute multiple queries in a loop. In this
case, my bean should hold up on one connection until the bean instance gets
gc'ed (for a request/ session scope bean)

For a bean that persists in application scope, I would close the connection
after query finishes.

Do pooled connections remain open in the container while idle ?

On 12/12/06, Christopher Schultz <[EMAIL PROTECTED]> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ran,

Ran wrote:
> My plan was to share an open-connection within a bean, pooled connection
> across beans.

Can you explain this in more detail? Did you mean that you wanted a
single connection for /permanent/ use within a bean, or did you mean
that you wanted to obtain a connection, use it for a series of queries,
and then return it when you are all done?

I'm having trouble thinking of a case where the first option makes sense
(unless that connection is special... for instance, it has different
privileges or special access). The second option is definitely what you
want to do.

If you are going to be running several queries in a row, you should
definitely re-use a connection that you already have, instead of
returning the connection to the pool after every query and then getting
another one for the next.

> Will it exhaust the pool ?

The only thing that will exhaust the pool is asking for too many
connections. When that happens, some requests will wait for a connection
to be returned to the pool before continuing (or, then may time out if
it takes too long).

You should attempt to hold on to database connections for as short a
time as possible in order to ensure the best perceived performance by
your users.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFfsuf9CaO5/Lv0PARAk1DAJ9PdnYkk3kGsE54Wd+QCoIhUQxP3ACeKflx
H+PA2ylEZhK6Lh4JZtDKFR8=
=4hNt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to