how about putting it into DynaActionForm::initialize which initialises the
beans anyhow..

-Martin

this way your connections are
----- Original Message ----- 
From: "Vic Cekvenich" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 22, 2003 9:31 AM
Subject: Re: How find DataSource?


> I put mine in a static block of the base DAO. (static as in once per
> class, and all DAO's extend my base DAO).
>
>
> .V
>
>
> e-denton Java Programmer wrote:
>
> > Merry Christmas,
> >
> > Wow, I finally connected to my data source! Now, I want to put the code
> > somewhere it will be executed only once, and save the DataSource object
> > where Actions, beans, etc. can get at it. That way, I don't have to
perform
> > the lookup all the time.
> >
> > Any suggestions on where to put the one time setup code, and where to
save
> > the DataSource object reference (in the application?).
> >
> > Thanks again,
> >
> > Will
> >
> > ----- Original Message ----- 
> > From: "Vic Cekvenich" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, December 20, 2003 12:14 PM
> > Subject: Re: How find DataSource?
> >
> >
> >
> >>See sample source code section here:
> >>
> >
> >
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
> >
> >>Ex:
> >>Context ctx = new InitialContext();
> >>       if(ctx == null )
> >>           throw new Exception("Boom - No Context");
> >>
> >>       DataSource ds =
> >>             (DataSource)ctx.lookup(
> >>                "java:comp/env/jdbc/TestDB");
> >>
> >>
> >>Of course what you do with the data source depends on your DAO
> >>implementataion (iBatis, Hibrenate, etc.)
> >>
> >>.V
> >>
> >>
> >>hylepc wrote:
> >>
> >>>Hi,
> >>>
> >>>From a Data Acess Object (DAO), I need to access a DataSource (like
> >>>getServletContext().getAttribute (Globals.DATA_SOURCE_KEY)). But, I
> >
> > don't
> >
> >>>have access to the servlet variable.
> >>>
> >>>What is the proper way to get the DataSource from a DAO which is called
> >
> > by
> >
> >>>an Action but doesn't extend Action?
> >>>
> >>>Thanks,
> >>>
> >>>Will
> >>
> >>
> >>---------------------------------------------------------------------
> >>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]

Reply via email to