John, read the posts on Connection Pool. I've got it working in 1.0.2 by
setting the "key" as an Attribute of the <datasource> tag not as a property.

struts-config file:

   <data-source key="one" >
     ...
     ... 
   </data-source> 

   <data-source>

     <set-property property="key" value="two" />
     ...
     ...        

   </data-source> 

Now in the Action Class:

ServletContext context = servlet.getServletContext();
DataSource dataSource = (DataSource)context.getAttribute("one");

OR you can cast it as a GenericDataSource to print out its properites:

ServletContext context = servlet.getServletContext();
org.apache.struts.util.GenericDataSource genSource = 
 
(org.apache.struts.util.GenericDataSource)context.getAttribute("one");
                
System.out.println(genSource.getDescription());
System.out.println(genSource.getDriverClass());
System.out.println(genSource.getUrl());

This works for Struts 1.0.2. Not sure if it will work with any other
version.

Thanks to Dennis Lee and David Graham!!

-----Original Message-----
From: John Wilson [mailto:[EMAIL PROTECTED]
Sent: March 20, 2003 3:54 AM
To: '[EMAIL PROTECTED]'
Subject: struts 1.1:Multiple DataSources 


Using struts 1.1 with SQL2000 Database.

Defined two data sources in my strust-conf.xml:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 <data-sources>

   <data-source>

     <set-property property="key" value="one" />
     ...
     ... 
   </data-source> 

   <data-source>

     <set-property property="key" value="two" />
     ...
     ...        

   </data-source> 

</data-sources>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


>From with in my action classes 

  dataSource = getDataSource(request,"one"); 
   or/
  dataSource = getDataSource(request,"two"); 

both of these throw a null pointer exception.

However  both work fine with getDataSource(request) when I define only one
datasource and don't pass in the key.

Does anyone have a solution or a reference web site?


thanks in Advance

John


 









---------------------------------------------------------------------
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]

Reply via email to