Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connection pool sharing

Status
Not open for further replies.

MultipartRequest

Programmer
Sep 12, 2001
19
CL
Lets say I have 5 servlets which all of them executes querys and updates to a database. The question is as follows. If in one of those servlets I create a connection pool, how can I share that connection with the other servlets, in order not to create one for each servlet.?
 
set the pool as an application variable

if connection pool has not yet been created, initiate pool and set as application variable

ConnPool conn = new ConnPool();
application.setAttribute("ConnPool", conn);

then every other time

ConnPool conn = (ConnPool)application.getAttribute("ConnPool");

This would allow every user on the site to reference this connection pool. If you only want the user who created the pool to be able to access it set it as a session attribute (just change application to session).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top