cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Parker" <rob...@webcybernetics.com>
Subject Re: sql tag-library
Date Tue, 09 May 2000 02:37:57 GMT

----- Original Message -----
From: Michele Bianchi <mic@exsense.com>
To: cocoon-users <cocoon-users@xml.apache.org>
Sent: Monday, May 08, 2000 4:15 AM
Subject: sql tag-library


>
snip...
> to change the dbms.  the second one to have a choice specify a
dbconnection
> or the dburl.  the db connection it's a really expensive operation it
seems
> imho to create a global var and reuse it.  please tell me if it is stupid,
cos
> i'm new in servlet programming.
>
Your on the right track in that opening a connection to a DB is an expensive
operation. I guess you're suggesting allocating a single global instance
which
persists for the lifetime of the 'servlet'. This does save the connection
overhead,
but you may run into some concurrency issues.

Consider what happens when the 'servlet' receives multiple concurrent
requests,
each request will result in a thread using your single DB connection. Hence
if the driver
is thread safe, all may be ok. If not you'll get strange behaviours. Now I'm
no expert, but as
far as I know a lot of drivers aren't thread safe. I believe some that are,
really just serialize
access to the database, hence your scalability is poor.

What you're after is a DB connection pool. This object acts like a factory
which hands out
connection objects on request. It maintains a collection of connections
ready to go, hence you
remove the connection overhead, and you get thread safety. There is a lot of
discussion at the
moment about integrating connection pools into the sql/xsp tag libraries.

hope this helps

Rob



Mime
View raw message