A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
Where to release database connection before servlet gets destroyed?
Joined: May 17, 2010
May 18, 2010 08:12:12
If I have database connection in my
Can only one database connection in init() method will handle multiple client request?
Where to release that connection before servlet gets destroyed.(Unloaded from memory.) ?
Joined: Dec 11, 2004
May 18, 2010 08:21:46
I wouldn't keep a database connection in a servlet. At best it would become that servlet's performance bottleneck.
You're more likely to run into other issues that would be worse.
Look into container managed connection pools.
It's the standard and a much better way to go.
How to ask a question...
Simple Servlet Examples
Joined: Jan 26, 2007
May 19, 2010 01:09:33
Connection should always be get and returned to the connection pool as it has many advantages.
And connection should be returned to the pool as soon as you don't need that. Keeping connection in servlet is bad
It is sorta covered in the
JavaRanch Style Guide
subject: Where to release database connection before servlet gets destroyed?
load-on-startup tag Vs listener
Connection Object pointing to Null
Connection Pooling and JSTL
NullPointerException running web applications.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014