You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shyamsunder Reddy <sj...@yahoo.com> on 2006/08/22 16:46:54 UTC

Using websphere datasource in Struts

What is the best place to call Websphere DataSource in Struts application. Instantiate it when ActionServlet is loaded and then pass onto Model classes as reference OR create a static class that instantiates the DataSource and getConnections from this class which should be Singleton
 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.

[OT] Re: Using websphere datasource in Struts

Posted by Antonio Petrelli <br...@tariffenet.it>.
Shyamsunder Reddy ha scritto:
> What is the best place to call Websphere DataSource in Struts application.

Eheh, it's not so simple :-)

> Instantiate it when ActionServlet is loaded and then pass onto Model classes as reference

ABSOLUTELY NOT!

>  OR create a static class that instantiates the DataSource and getConnections from this class which should be Singleton
>   

Do not use singleton in web application, because it raises several 
problem during reloading the webapp.

Instead, you could use a container-managed datasource to call through JNDI:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

Or use Spring or a similar IoC container to configure your Model (this 
is what I prefer to do):
http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-value-element

HTH
Antonio

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