By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,037 Members | 1,839 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,037 IT Pros & Developers. It's quick & easy.

Holding Static data links?

P: n/a

Hello!

I have designed a website with a servlet that holds on to a database
connection statically so as not to have to re-establish the data connection
with every single page request. (and it detects if the link went down, of
course). This connection has a bunch of prepared statements on it to make
things easier.

Now, the question is: Am I begging for trouble by doing this? What
happens if two page requests come in extremely close together? Is there a
guarantee that the servlet will only process one page at a time? Could it
be that two page requests will come in and cause the database connections
to step on each other?

Thanks!

mark.

--
-- I am not an ANGRY man. Take the rage out of my e-mail address to reply
please.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mark,

Servlets are multi-threaded -- if you're saying that each instance of your
servlet gets its own database connection (preferrably from a connection
pool), then you should be okay. On the other hand, if you have a database
connection that is a singleton object that you're sharing between servlet
threads, i believe you may be asking for trouble.

I'd recommend utilizing third party connection pooling software, as it will
take care of 'dead' connections, keeping a min/max # of connections open,
etc. For decent open-source connection pooling software, check out
http://proxool.sourceforge.net/.

Steve David

Mark <ne**@ANGRYlanfear.com> wrote in message news:<R7v2c.130526$4o.169281@attbi_s52>...
Hello!

I have designed a website with a servlet that holds on to a database
connection statically so as not to have to re-establish the data connection
with every single page request. (and it detects if the link went down, of
course). This connection has a bunch of prepared statements on it to make
things easier.

Now, the question is: Am I begging for trouble by doing this? What
happens if two page requests come in extremely close together? Is there a
guarantee that the servlet will only process one page at a time? Could it
be that two page requests will come in and cause the database connections
to step on each other?

Thanks!

mark.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.