You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Antonio Petrelli <br...@tariffenet.it> on 2006/08/22 17:12:06 UTC

[OT] Re: Using websphere datasource in Struts

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