You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2003/08/15 16:59:41 UTC

get data source in servlet

Hi,

I am using struts 1.1 and have defined a data source
for connection pooling, in my Action class i get the
data source by using simple
 DataSource dataSourceA = getDataSource(request, "A");
 Connection myConnection =
dataSourceA.getConnection();

But now i need to get the data source in a servlet
which does not extend Action class, but HttpServlet
can any one provide code for it

Ashish


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: get data source in servlet

Posted by Paul Thomas <pa...@tmsl.demon.co.uk>.
On 15/08/2003 15:59 Ashish Kulkarni wrote:
> Hi,
> 
> I am using struts 1.1 and have defined a data source
> for connection pooling, in my Action class i get the
> data source by using simple
>  DataSource dataSourceA = getDataSource(request, "A");
>  Connection myConnection =
> dataSourceA.getConnection();
> 
> But now i need to get the data source in a servlet
> which does not extend Action class, but HttpServlet
> can any one provide code for it

One way would be to put the datasource in the session - the servlet could 
get it from there. Alternately you could use JNDI to access the datasource 
instead of having it configured in your Struts config file.

HTH

-- 
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller 
Business |
| Computer Consultants         | 
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org