subclass dispatch action. in execute method store the results from your jndi lookup in the servlet context then pass it to your data access objects which will then get connections from container pool(or your own). you only want to do the lookup once. if its ejb, you'll need to duplicate similar arrangement in that container.
----- Original Message ----- From: "Tolle Krez" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, February 05, 2003 8:42 PM Subject: Re: Design and Datasource question > I dont think it is good practice to pass datasource from Action class to your business > beans. > http://marc.theaimsgroup.com/?l=struts-user&m=104333643909577&w=2 > http://marc.theaimsgroup.com/?l=struts-user&m=104182416102397&w=2 > > I feel using JNDI to get datasource is the best choice. Others - i should have searched > the archives properly. i apologize. > > Thanks > > ----- Original Message ----- > From: "Vic Cekvenich" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, February 05, 2003 7:44 PM > Subject: Re: Design and Datasource question > > > > Some people get a connection in Action, and pass it in many ways to DAO. > > > > I get a connection in DAO (via DBCP). Ex: > > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/b asicWebLib/org > /apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2&content-type=text/vnd.view cvs-markup > > > > .V > > > > Tolle Krez wrote: > > > I am a newbie to struts and started with the struts-example application. And modified > it > > > a bit and learning.. . It looks like there are no separate model classes and all > business > > > logic exists in the Action classes itself. I am thinking of separate them. The > Datasource > > > settings are in my struts-config file and they are obtained in the Action class using > > > servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) . > > > > > > My question is, if I separate the business logic and database access away from Action > > > classes, how to I do get access to the datasource and connection pool. > > > > > > PS: I am not using EJB and only plain java classes to access the database and for > > > business logics. > > > > > > Any help is appreciated > > > > > > T > > > > > > > > --------------------------------------------------------------------- > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]