You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "George Henry C. Daswani" <gd...@odc.net> on 2000/12/06 23:25:24 UTC

How does one get an instance of the GenericDataSource?

Hello,

	I've editted the configuration in my "struts-config.xml" and added
a data source.  I'm wondering, how does one grab an instance of a generic
data source so that I get do a getConnection on it..

By default, is it dumped into the servlet context?  if so, what attribute
name?

Is it dumped into the servlet request and tagged via an attribute name?
if so, what name?

I'm trying to access it from an Action:perform method which has input
parameters of ActionMapping, ActionForm, HttpServletRequest, and
HttpServletResponse.

George

-- 


Re: How does one get an instance of the GenericDataSource?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"George Henry C. Daswani" wrote:

> Hello,
>
>         I've editted the configuration in my "struts-config.xml" and added
> a data source.  I'm wondering, how does one grab an instance of a generic
> data source so that I get do a getConnection on it..
>
> By default, is it dumped into the servlet context?  if so, what attribute
> name?
>
> Is it dumped into the servlet request and tagged via an attribute name?
> if so, what name?
>

Yes, it is.  The name it's stored under is the public string constant
Action.DATA_SOURCE_KEY (the actual value is
"org.apache.struts.action.DATA_SOURCE").

>
> I'm trying to access it from an Action:perform method which has input
> parameters of ActionMapping, ActionForm, HttpServletRequest, and
> HttpServletResponse.

    DataSource ds = (DataSource)
      servlet.getServletContext().getAttribute(Action.DATA_SOURCE);

Better documentation is on the way!

>
> George
>
> --

Craig McClanahan