Wow, my personal saga of discovery continues... Apparently I have been trying to set up connection pooling *both* in server.xml context *and* in web.xml unnecessarily. Well, the server.xml works, but then I have the problem of where to store the DataStore object and how my Data Access Objects will access it.
Has anyone set up a connection pool using web.xml? Steps? Examples? Tips? I can't even seem to change the driver without problems. And, web.xml doesn't use JNDI, does it? Has anyone used server.xml instead? Where did you keep the DataSource Object? I looked into keeping it in the session, but then I have to pass session to my DAOs--ick. (I am writing my own DAOs.) Vic, I might have two problems with keeping it in a static block. 1. My container can be passivated, so everything must be serializable. 2. I hope to only look it up once for efficiency's sake. Martin, I assume you mean to extend DynaActionForm and override initialize, but that means tying myself to Struts. (Like I'm not already!) Ideally, I shouldn't have to modify the framework. Thanks, Will ----- Original Message ----- From: "Martin Gainty" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, December 22, 2003 1:41 PM Subject: Re: How find DataSource? > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]