Hi,

Here is my code snippet:

                // initialization - Datasource and Name Service
                log.info("Initializing configuration plug in : Datasource
and Name service");
                DataSource dataSource = null;
                if (StringUtils.isEmpty(desconfig.getDatasource())) {
                        dataSource = (DataSource)
servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
                } else {
                        dataSource = (DataSource)
servlet.getServletContext().getAttribute(desconfig.getDatasource());
        
servlet.getServletContext().setAttribute(Action.DATA_SOURCE_KEY,
dataSource);
                }

Note:
desconfig.getDatasource() returns a String of my datasource key.
I set the the retrieved datasource to Action.DATA_SOURCE_KEY to easy later
access.

It works for me.

Best Regards,
Dennis Lee

-----Original Message-----
From: Jimmy Emmanual [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 9:59 AM
To: 'Struts Users Mailing List'
Subject: RE: Connection Pool


Also, it seems when you have a list of datasources, the only one that is
recognized is the last one...

-----Original Message-----
From: David Graham [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 7:29 PM
To: [EMAIL PROTECTED]
Subject: RE: Connection Pool


Are you using modules? Why don't you print out the contents of 
ServletContext to see if it's in there?

David



>From: Jimmy Emmanual <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: RE: Connection Pool
>Date: Wed, 19 Mar 2003 19:23:40 -0500
>
>David,
>
>When i try to access it via the defined key, the DataSource object is null.
>The only way it works is if i use the "Action.DATA_SOURCE_KEY" i.e.
>
>ServletContext context = servlet.getServletContext();
>DataSource dataSource =
>(DataSource)context.getAttribute(Action.DATA_SOURCE_KEY);
>
>If i try something like:
>
>ServletContext context = servlet.getServletContext();
>DataSource dataSource = (DataSource)context.getAttribute("Datasource1");
>
>where "Datasource1" is the "key" in the struts-config.xml file, it doesn't
>work...
>
>-----Original Message-----
>From: David Graham [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, March 19, 2003 7:23 PM
>To: [EMAIL PROTECTED]
>Subject: Re: Connection Pool
>
>
>Struts stores the DataSources in the ServletContext under the key you
>defined.
>
>David
>
>
>
> >From: Jimmy Emmanual <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> >Subject: Connection Pool
> >Date: Wed, 19 Mar 2003 19:18:11 -0500
> >
> >How do you access a DataSource from an action class via its "key"? I have
> >multiple DataSources defined in the struts-config.xml file each have the
> >"key" property set. I need to access these based on this "key".
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*
>http://join.msn.com/?page=features/junkmail
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


**********************************************************************
This message and any files transmitted with it are confidential and
may be privileged and/or subject to the provision of privacy legislation.
They are intended solely for the use of the individual or entity to whom they are 
addressed. If the reader of this message is not the intended
recipient, please notify the sender immediately and then delete this
message. You are notifed that reliance on, disclosure of, distribution or
copying of this message is prohibited.
Bank of Bermuda
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to