struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <brenmcgu...@tariffenet.it>
Subject [OT] Re: Using websphere datasource in Struts
Date Tue, 22 Aug 2006 15:12:06 GMT
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


Mime
View raw message