atom feed5 messages in org.apache.tomcat.usersRe: Connection Pool with JavaServlet ...
FromSent OnAttachments
Harald RufJun 20, 2000 8:54 am 
Jon BaerJun 20, 2000 9:31 am 
Craig R. McClanahanJun 20, 2000 9:42 am 
Craig R. McClanahanJun 20, 2000 3:29 pm 
Nimphy, ThomasJun 20, 2000 11:02 pm 
Subject:Re: Connection Pool with JavaServlet API 2.2
From:Craig R. McClanahan (Crai@eng.sun.com)
Date:Jun 20, 2000 9:42:06 am
List:org.apache.tomcat.users

Harald Ruf wrote:

Hallo,I have just upgrade my apache server from jserv to tomcat3.1. Now my connection pool, base on a servlet(this holds the connection to the database), doesn#t work because the 'getServlet()'-method (ServletContext) is now deprecated and always returns null. Have anybody another solution of connection pooling? Can anybody sen me a code example. Thanks a lotHarald

The suggested approach is to store your connection pool object itself as a servlet context attribute, like this:

ConnectionPool pool = new ConnectionPool( ... ); getServletContext().setAttribute("pool", pool);

Now, any servlet (or JSP page) in this web application can gain access to the connection pool:

ConnectionPool pool = (ConnectionPool) getServletContext().getAttribute("pool");

without needing to gain access to a servlet instance itself.

Craig McClanahan