You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ge...@fmo.com on 2004/01/12 17:32:06 UTC

Best Practice for data source access

What is the best practice for establishing a data source connection using 
JNDI.
I am using the DAO pattern for database access but where is the best 
location for placing the code that initializes the data source?
I am using connection pooling.
I am moving a Struts application into a Portlet.
The core servlet is com.ibm.wps.portlets.struts.WpsStrutsPortlet.

Thanks

Re: Best Practice for data source access

Posted by Christian Bollmeyer <ja...@christianbollmeyer.de>.
Am Montag, 12. Januar 2004 17:32 schrieb Gerald_Beattie@fmo.com:
> What is the best practice for establishing a data source connection
> using JNDI.
> I am using the DAO pattern for database access but where is the best
> location for placing the code that initializes the data source?
> I am using connection pooling.
> I am moving a Struts application into a Portlet.
> The core servlet is com.ibm.wps.portlets.struts.WpsStrutsPortlet.

For global initialization, we usually use a 'resource' listener
(a simple class with 2 methods implementing ServletContextListener)
that fires up all the Singletons and initializes the DAO and
SessionFacade, among other things. Another approach would be
to use static initializers (static {...;}). For details about the latter 
approach, check out the excellent manual for iBATIS (www.ibatis.com),
an open source OR mapping solution you might want to adapt
your DAO to as well.

> Thanks

HTH,
-- Chris.


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