> -----Original Message----- > From: Saurabh Bhatla [mailto:[EMAIL PROTECTED] > Sent: Monday, August 16, 2004 3:16 PM > To: Struts Users Mailing List > Subject: RE: connection pooling > > > Jim, > I understand most part of it now. the only thing that i dont > understand is how will the connection pooling be handled. I am using > tomcat 5. will the following code(from the link that u sent me) serve > the purpose? > > <data-sources> > <!-- configuration for commons BasicDataSource --> > <data-source type="org.apache.commons.dbcp.BasicDataSource"> > <set-property > property="driverClassName" > value="org.postgresql.Driver" /> > <set-property > property="url" > value="jdbc:postgresql://localhost/mydatabase" /> > <set-property > property="username" > value="me" />
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations The short version is that it is handled automagically for you. No need to borrow or return the connection etc. > . > . > . > ...... > > regards > saurabh > > > > On Mon, 2004-08-16 at 16:45, Jim Barrows wrote: > > > -----Original Message----- > > > From: Saurabh Bhatla [mailto:[EMAIL PROTECTED] > > > Sent: Monday, August 16, 2004 2:42 PM > > > To: Struts Users Mailing List > > > Subject: RE: connection pooling > > > > > > > > > Jim, > > > I am sorry but I am confused now. Just correct me if I am > > > wrong........ I want to call my DAO from my Action class. So > > > the snippet > > > that you sent me would go in my DAO class in the function > > > getConnection() (or something like that). > > > > Yes, that is correct. I acutally implment that in my > DaoFactory class, and put the resultant connection from the > data source in the DaoFactory class. That allows me to > easily de-couple the dao class for testing. > > > > > And if what I said is correct then does it mean that I > > > dont need to > > > have a connection pool class and my webserver would > handle everything > > > for me. > > > > Depends on the web server... websphere has it's own, tomcat > allows you to have several choices, and I have no idea what BEA does. > > > > > > > > > > regards > > > saurabh > > > > > > On Mon, 2004-08-16 at 16:29, Jim Barrows wrote: > > > > > -----Original Message----- > > > > > From: Saurabh Bhatla [mailto:[EMAIL PROTECTED] > > > > > Sent: Monday, August 16, 2004 2:24 PM > > > > > To: Struts Users Mailing List > > > > > Subject: Re: connection pooling > > > > > > > > > > > > > > > David, > > > > > But i want to make a business layer and call the DAO > > > from there. I > > > > > think that the links that you have sent me couple > > > > > presentation layer and > > > > > database tightly. I know i can use EJB for presentation layer > > > > > but I dont > > > > > want that as it would be overkill for the small project I am > > > > > working on. > > > > > I want to have a connection pool class initialized at > the time the > > > > > server starts and then all my DAO should get the > > > connection from that > > > > > pool. Is it possible? > > > > > I am a beginner in this field and I might not understand it > > > > > completely. please correct me if i am wrong. > > > > > > > > Ah, okay.. I also posted a link to the struts way to do the > > > JNDI data source stuff.... in that case.. you follow your web > > > app servers guide on how to setup a data source, then you > > > follow the destructions for a normal jndi data source. > Something like: > > > > > > > > /** > > > > * > > > > */ > > > > public static DataSource getDataSource() throws > > > NamingException { > > > > if (ds == null) { > > > > Context ctx = (Context) new InitialContext(); > > > > ds = > > > > (DataSource) ctx.lookup( > > > > "jdbc/yourDataSource); > > > > } > > > > return ds; > > > > } > > > > > > > > > regards > > > > > saurabh > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > 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] > > > > > > > --------------------------------------------------------------------- > 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]