Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old February 25th, 2001, 02:17 AM
Vijaya Vijaya is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 0 Vijaya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry

Hi,

I have a problem in maintaining the open database connection objects in servlets. How to do this? Once, i connect to the database from one servlet or page. It should be opened for all the servlets which uses sql statements. Every servlet or page should not make a new connection.

Vijaya.
Comments on this post
Gran Roguismo agrees!

Reply With Quote
  #2  
Old February 25th, 2001, 11:57 PM
hoi hoi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: NY
Posts: 0 hoi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hoi
Smile try to put the

hi there,

you can create a connection in one servlet..
then put in into ServletContext.
e.g. In "AServlet.class" :

Connection con = .....
ServletContext sc = getServletConfig().getServletContext();
sc.setAttribute("con", con);

and in "BServlet.class", you can retrieve this connection
by doing:

Connection con = null;
ServletContext sc = getServletConfig().getServletContext();
con = (Connection)sc.getAttribute("con");

and do whatever you want in "BServlet.class".
try it... it'd better to create a ConnectionPool class
to give out connection... therefore each servlet
will get their own connection and return it back to
the ConnectionPool once they finish.

good luck.
-hoi.
Comments on this post
Gran Roguismo agrees!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Database Connectivity in Servlets


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway