A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
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?
NullPointerException running web applications.
Connection Pooling and JSTL
load-on-startup tag Vs listener
Connection Object pointing to Null
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014