This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Constant JDBC Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Constant JDBC Connection" Watch "Constant JDBC Connection" New topic
Author

Constant JDBC Connection

Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
On my webpage visitors will frequently make database querys. Is it possible to run a connection in the background that all servlets will be able to tap into? Like a constantly logged in helper that is available to all servlets? How would I do this?

Thanks for atleast reading things,
-D.P.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Your best bet in such an environment is container-managed connection pooling.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

An old thread that discusses this in length just resurfaced today.
http://www.coderanch.com/t/360733/Servlets/java/it-good-carry-jdbc-Connection


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Constant JDBC Connection