Re: Connection Pooling with Struts
Sure I will For time being I used DBCP. Anjib On 12/8/2010 12:54 PM, adam pinder wrote: Anjib, i'd certainly take a look at hibernate, i've been using it for a while now and find it easy enough and functionally rich enough for most things. adam Date: Tue, 7 Dec 2010 14:36:01 -0500 From: anji...@hotmail.com To: user@struts.apache.org Subject: Connection Pooling with Struts I have to do DB connection (Oracle 10g) in my application developed in Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me how to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Connection Pooling with Struts
Anjib, i'd certainly take a look at hibernate, i've been using it for a while now and find it easy enough and functionally rich enough for most things. adam > Date: Tue, 7 Dec 2010 14:36:01 -0500 > From: anji...@hotmail.com > To: user@struts.apache.org > Subject: Connection Pooling with Struts > > I have to do DB connection (Oracle 10g) in my application developed in > Struts 1.3.8. > > Currently I am implementing JDBC. As far I understand this is not a good > technique for real project. So I am hoping someone could suggest me how > to do DB handling efficiently? > > Thanks > Anjib > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
RE: Connection Pooling with Struts
careful stan..he has a PhD from an Indian University! Martin __ Man1: in my next life I want to be an attorney from the Middle-East Man1: why do you want to be an attorney from the Middle-East? Man1: so i can work for an American Company > Date: Tue, 7 Dec 2010 16:19:48 -0600 > Subject: Re: Connection Pooling with Struts > From: stanl...@gmail.com > To: user@struts.apache.org > > Dude, I can't sit quietly any longer! How you connect to a database has > NOTHING WHATSOEVER to do with the Struts/2 Framework. I would advise you to > keep the two separated in your mind. Much like you wouldn't look to a > Database connection to serve a web page, neither should you look to Struts/2 > as a Database connection. > > On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: > > > So I can use this DBCP Componenet instead of framework? > > > > Anjib > > > > E.g -. http://commons.apache.org/dbcp/ > >> > >> On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton > >> wrote: > >> > >> A connection pooling library? > >>> > >>> On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati > >>> wrote: > >>> > >>> Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) > >>>> handle connection pooling. So framework make work easy. If framework is > >>>> > >>> not > >>> > >>>> used what are other alternatives to handle connection pooling beside > >>>> JDBC > >>>> itself? > >>>> > >>>> Anjib > >>>> > >>>> > >>>> On 12/7/2010 4:20 PM, Arthur Neves wrote: > >>>> > >>>> Nop, > >>>>> > >>>>> You dont need using a framework... if you pick one just will make your > >>>>> life > >>>>> easier! > >>>>> If you`re starting a new project I`d get one framework, however if the > >>>>> project it`s already ready, just keep doing in the same way! > >>>>> > >>>>> On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati > >>>>> wrote: > >>>>> > >>>>> I was thinking for Hibernate. > >>>>> > >>>>>> So only way for struts is use one of these framework? > >>>>>> > >>>>>> Anjib > >>>>>> > >>>>>> > >>>>>> On 12/7/2010 3:26 PM, Johannes Geppert wrote: > >>>>>> > >>>>>> in java you have the choose which way is the best for your project to > >>>>>> > >>>>>>> handle > >>>>>>> databases. > >>>>>>> > >>>>>>> there exists several frameworks for this job like hibernate, myBatis, > >>>>>>> spring > >>>>>>> jdbc tempalate, ... . > >>>>>>> google for it and look which framework is the best for your project. > >>>>>>> > >>>>>>> Johannes > >>>>>>> > >>>>>>> > >>>>>>> anjibman wrote: > >>>>>>> > >>>>>>> I have to do DB connection (Oracle 10g) in my application developed > >>>>>>> > >>>>>> in > >>> > >>>> Struts 1.3.8. > >>>>>>>> > >>>>>>>> Currently I am implementing JDBC. As far I understand this is not a > >>>>>>>> good > >>>>>>>> technique for real project. So I am hoping someone could suggest me > >>>>>>>> > >>>>>>> how > >>> > >>>> to do DB handling efficiently? > >>>>>>>> > >>>>>>>> Thanks > >>>>>>>> Anjib > >>>>>>>> > >>>>>>>> > >>>>>>>> - > >>>>>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>>>>>>> For additional commands, e-mail: user-h...@struts.apache.org > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> - > >>>>>>>> > >>>>>>> --- > >>>>>>> web: http://www.jgeppert.com > >>>>>>> twitter: http://twitter.com/jogep > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> - > >>>>>>> > >>>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>>>>> For additional commands, e-mail: user-h...@struts.apache.org > >>>>>> > >>>>>> > >>>>>> > >>>>>> - > >>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>>> For additional commands, e-mail: user-h...@struts.apache.org > >>>> > >>>> > >>>> > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > >
Re: Connection Pooling with Struts
Then you should be asking on the appropriate list. http://www.catb.org/~esr/faqs/smart-questions.html#forum On Tue, Dec 7, 2010 at 6:15 PM, Anjib wrote: > > Dude > I am asking about ORM tool not Struts framework itself. > > Please see the reply from Johannes. > > Thanks > Anjib > > > On 12/7/2010 5:19 PM, stanl...@gmail.com wrote: > >> Dude, I can't sit quietly any longer! How you connect to a database has >> NOTHING WHATSOEVER to do with the Struts/2 Framework. I would advise you >> to >> keep the two separated in your mind. Much like you wouldn't look to a >> Database connection to serve a web page, neither should you look to >> Struts/2 >> as a Database connection. >> >> On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati >> wrote: >> >> So I can use this DBCP Componenet instead of framework? >>> >>> Anjib >>> >>> E.g -. http://commons.apache.org/dbcp/ >>> On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton wrote: A connection pooling library? > On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati > wrote: > > Ok now I get confuse. I was thinking simple JDBC can't (or complex to > ) > >> handle connection pooling. So framework make work easy. If framework >> is >> >> not > > used what are other alternatives to handle connection pooling beside >> JDBC >> itself? >> >> Anjib >> >> >> On 12/7/2010 4:20 PM, Arthur Neves wrote: >> >> Nop, >> >>> You dont need using a framework... if you pick one just will make >>> your >>> life >>> easier! >>> If you`re starting a new project I`d get one framework, however if >>> the >>> project it`s already ready, just keep doing in the same way! >>> >>> On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati >>> wrote: >>> >>> I was thinking for Hibernate. >>> >>> So only way for struts is use one of these framework? Anjib On 12/7/2010 3:26 PM, Johannes Geppert wrote: in java you have the choose which way is the best for your project to handle > databases. > > there exists several frameworks for this job like hibernate, > myBatis, > spring > jdbc tempalate, ... . > google for it and look which framework is the best for your > project. > > Johannes > > > anjibman wrote: > > I have to do DB connection (Oracle 10g) in my application > developed > > in >>> Struts 1.3.8. >> >>> Currently I am implementing JDBC. As far I understand this is not a >> good >> technique for real project. So I am hoping someone could suggest >> me >> >> how > to do DB handling efficiently? >> >>> Thanks >> Anjib >> >> >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> >> >> >> - >> >> --- > web: http://www.jgeppert.com > twitter: http://twitter.com/jogep > > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> >> >> - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >>> > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Connection Pooling with Struts
On Tue, Dec 7, 2010 at 6:15 PM, Anjib wrote: > I am asking about ORM tool not Struts framework itself. > I think the point was more along the lines of "why are you asking here," since you're not asking about the Struts framework. Dave
Re: Connection Pooling with Struts
Dude I am asking about ORM tool not Struts framework itself. Please see the reply from Johannes. Thanks Anjib On 12/7/2010 5:19 PM, stanl...@gmail.com wrote: Dude, I can't sit quietly any longer! How you connect to a database has NOTHING WHATSOEVER to do with the Struts/2 Framework. I would advise you to keep the two separated in your mind. Much like you wouldn't look to a Database connection to serve a web page, neither should you look to Struts/2 as a Database connection. On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: So I can use this DBCP Componenet instead of framework? Anjib E.g -. http://commons.apache.org/dbcp/ On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton wrote: A connection pooling library? On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati wrote: Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) handle connection pooling. So framework make work easy. If framework is not used what are other alternatives to handle connection pooling beside JDBC itself? Anjib On 12/7/2010 4:20 PM, Arthur Neves wrote: Nop, You dont need using a framework... if you pick one just will make your life easier! If you`re starting a new project I`d get one framework, however if the project it`s already ready, just keep doing in the same way! On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: I was thinking for Hibernate. So only way for struts is use one of these framework? Anjib On 12/7/2010 3:26 PM, Johannes Geppert wrote: in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: I have to do DB connection (Oracle 10g) in my application developed in Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me how to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Connection Pooling with Struts
Dude, I can't sit quietly any longer! How you connect to a database has NOTHING WHATSOEVER to do with the Struts/2 Framework. I would advise you to keep the two separated in your mind. Much like you wouldn't look to a Database connection to serve a web page, neither should you look to Struts/2 as a Database connection. On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: > So I can use this DBCP Componenet instead of framework? > > Anjib > > E.g -. http://commons.apache.org/dbcp/ >> >> On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton >> wrote: >> >> A connection pooling library? >>> >>> On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati >>> wrote: >>> >>> Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) handle connection pooling. So framework make work easy. If framework is >>> not >>> used what are other alternatives to handle connection pooling beside JDBC itself? Anjib On 12/7/2010 4:20 PM, Arthur Neves wrote: Nop, > > You dont need using a framework... if you pick one just will make your > life > easier! > If you`re starting a new project I`d get one framework, however if the > project it`s already ready, just keep doing in the same way! > > On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati > wrote: > > I was thinking for Hibernate. > >> So only way for struts is use one of these framework? >> >> Anjib >> >> >> On 12/7/2010 3:26 PM, Johannes Geppert wrote: >> >> in java you have the choose which way is the best for your project to >> >>> handle >>> databases. >>> >>> there exists several frameworks for this job like hibernate, myBatis, >>> spring >>> jdbc tempalate, ... . >>> google for it and look which framework is the best for your project. >>> >>> Johannes >>> >>> >>> anjibman wrote: >>> >>> I have to do DB connection (Oracle 10g) in my application developed >>> >> in >>> Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me >>> how >>> to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - >>> --- >>> web: http://www.jgeppert.com >>> twitter: http://twitter.com/jogep >>> >>> >>> >>> - >>> >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> >> >> - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Connection Pooling with Struts
So I can use this DBCP Componenet instead of framework? Anjib E.g -. http://commons.apache.org/dbcp/ On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton wrote: A connection pooling library? On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati wrote: Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) handle connection pooling. So framework make work easy. If framework is not used what are other alternatives to handle connection pooling beside JDBC itself? Anjib On 12/7/2010 4:20 PM, Arthur Neves wrote: Nop, You dont need using a framework... if you pick one just will make your life easier! If you`re starting a new project I`d get one framework, however if the project it`s already ready, just keep doing in the same way! On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: I was thinking for Hibernate. So only way for struts is use one of these framework? Anjib On 12/7/2010 3:26 PM, Johannes Geppert wrote: in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: I have to do DB connection (Oracle 10g) in my application developed in Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me how to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Connection Pooling with Struts
E.g -. http://commons.apache.org/dbcp/ On Tue, Dec 7, 2010 at 4:27 PM, Dave Newton wrote: > A connection pooling library? > > On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati > wrote: > > > Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) > > handle connection pooling. So framework make work easy. If framework is > not > > used what are other alternatives to handle connection pooling beside JDBC > > itself? > > > > Anjib > > > > > > On 12/7/2010 4:20 PM, Arthur Neves wrote: > > > >> Nop, > >> > >> You dont need using a framework... if you pick one just will make your > >> life > >> easier! > >> If you`re starting a new project I`d get one framework, however if the > >> project it`s already ready, just keep doing in the same way! > >> > >> On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati > >> wrote: > >> > >> I was thinking for Hibernate. > >>> So only way for struts is use one of these framework? > >>> > >>> Anjib > >>> > >>> > >>> On 12/7/2010 3:26 PM, Johannes Geppert wrote: > >>> > >>> in java you have the choose which way is the best for your project to > handle > databases. > > there exists several frameworks for this job like hibernate, myBatis, > spring > jdbc tempalate, ... . > google for it and look which framework is the best for your project. > > Johannes > > > anjibman wrote: > > I have to do DB connection (Oracle 10g) in my application developed > in > > Struts 1.3.8. > > > > Currently I am implementing JDBC. As far I understand this is not a > > good > > technique for real project. So I am hoping someone could suggest me > how > > to do DB handling efficiently? > > > > Thanks > > Anjib > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > > > - > --- > web: http://www.jgeppert.com > twitter: http://twitter.com/jogep > > > - > >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>> For additional commands, e-mail: user-h...@struts.apache.org > >>> > >>> > >>> > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > >
Re: Connection Pooling with Struts
A connection pooling library? On Tue, Dec 7, 2010 at 4:25 PM, Anjib Mulepati wrote: > Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) > handle connection pooling. So framework make work easy. If framework is not > used what are other alternatives to handle connection pooling beside JDBC > itself? > > Anjib > > > On 12/7/2010 4:20 PM, Arthur Neves wrote: > >> Nop, >> >> You dont need using a framework... if you pick one just will make your >> life >> easier! >> If you`re starting a new project I`d get one framework, however if the >> project it`s already ready, just keep doing in the same way! >> >> On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati >> wrote: >> >> I was thinking for Hibernate. >>> So only way for struts is use one of these framework? >>> >>> Anjib >>> >>> >>> On 12/7/2010 3:26 PM, Johannes Geppert wrote: >>> >>> in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: I have to do DB connection (Oracle 10g) in my application developed in > Struts 1.3.8. > > Currently I am implementing JDBC. As far I understand this is not a > good > technique for real project. So I am hoping someone could suggest me how > to do DB handling efficiently? > > Thanks > Anjib > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > > > - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >>> > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Connection Pooling with Struts
Ok now I get confuse. I was thinking simple JDBC can't (or complex to ) handle connection pooling. So framework make work easy. If framework is not used what are other alternatives to handle connection pooling beside JDBC itself? Anjib On 12/7/2010 4:20 PM, Arthur Neves wrote: Nop, You dont need using a framework... if you pick one just will make your life easier! If you`re starting a new project I`d get one framework, however if the project it`s already ready, just keep doing in the same way! On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: I was thinking for Hibernate. So only way for struts is use one of these framework? Anjib On 12/7/2010 3:26 PM, Johannes Geppert wrote: in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: I have to do DB connection (Oracle 10g) in my application developed in Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me how to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Connection Pooling with Struts
Is the question about connection pooling, as the subject line indicates, or is the question about generic DB handling and JDBC v. ORMs? Dave On Tue, Dec 7, 2010 at 4:20 PM, Arthur Neves wrote: > Nop, > > You dont need using a framework... if you pick one just will make your life > easier! > If you`re starting a new project I`d get one framework, however if the > project it`s already ready, just keep doing in the same way! > > On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati > wrote: > > > I was thinking for Hibernate. > > So only way for struts is use one of these framework? > > > > Anjib > > > > > > On 12/7/2010 3:26 PM, Johannes Geppert wrote: > > > >> in java you have the choose which way is the best for your project to > >> handle > >> databases. > >> > >> there exists several frameworks for this job like hibernate, myBatis, > >> spring > >> jdbc tempalate, ... . > >> google for it and look which framework is the best for your project. > >> > >> Johannes > >> > >> > >> anjibman wrote: > >> > >>> I have to do DB connection (Oracle 10g) in my application developed in > >>> Struts 1.3.8. > >>> > >>> Currently I am implementing JDBC. As far I understand this is not a > good > >>> technique for real project. So I am hoping someone could suggest me how > >>> to do DB handling efficiently? > >>> > >>> Thanks > >>> Anjib > >>> > >>> - > >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>> For additional commands, e-mail: user-h...@struts.apache.org > >>> > >>> > >>> > >>> > >> - > >> --- > >> web: http://www.jgeppert.com > >> twitter: http://twitter.com/jogep > >> > >> > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > >
Re: Connection Pooling with Struts
Nop, You dont need using a framework... if you pick one just will make your life easier! If you`re starting a new project I`d get one framework, however if the project it`s already ready, just keep doing in the same way! On Tue, Dec 7, 2010 at 3:36 PM, Anjib Mulepati wrote: > I was thinking for Hibernate. > So only way for struts is use one of these framework? > > Anjib > > > On 12/7/2010 3:26 PM, Johannes Geppert wrote: > >> in java you have the choose which way is the best for your project to >> handle >> databases. >> >> there exists several frameworks for this job like hibernate, myBatis, >> spring >> jdbc tempalate, ... . >> google for it and look which framework is the best for your project. >> >> Johannes >> >> >> anjibman wrote: >> >>> I have to do DB connection (Oracle 10g) in my application developed in >>> Struts 1.3.8. >>> >>> Currently I am implementing JDBC. As far I understand this is not a good >>> technique for real project. So I am hoping someone could suggest me how >>> to do DB handling efficiently? >>> >>> Thanks >>> Anjib >>> >>> - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >>> >>> >> - >> --- >> web: http://www.jgeppert.com >> twitter: http://twitter.com/jogep >> >> > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Connection Pooling with Struts
I was thinking for Hibernate. So only way for struts is use one of these framework? Anjib On 12/7/2010 3:26 PM, Johannes Geppert wrote: in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: I have to do DB connection (Oracle 10g) in my application developed in Struts 1.3.8. Currently I am implementing JDBC. As far I understand this is not a good technique for real project. So I am hoping someone could suggest me how to do DB handling efficiently? Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Connection Pooling with Struts
in java you have the choose which way is the best for your project to handle databases. there exists several frameworks for this job like hibernate, myBatis, spring jdbc tempalate, ... . google for it and look which framework is the best for your project. Johannes anjibman wrote: > > I have to do DB connection (Oracle 10g) in my application developed in > Struts 1.3.8. > > Currently I am implementing JDBC. As far I understand this is not a good > technique for real project. So I am hoping someone could suggest me how > to do DB handling efficiently? > > Thanks > Anjib > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > - --- web: http://www.jgeppert.com twitter: http://twitter.com/jogep -- View this message in context: http://old.nabble.com/Connection-Pooling-with-Struts-tp30399631p30400023.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Connection Pooling How To ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jasdeep, jasdeep wrote: > Yes this is peek load actually .. The requests are through SMS's which > is forwarded by kannel server to my application . actually we are in > development phase and we are testing it as per client specifications. > > So this was the load client specified ... i had set the max limit of > my pool to 100 ... that may be the problem . i will go and increase it > now... If you need to serve 200 requests per second, ten you need to evaluate what percentage of requests result in DB connection use, and then estimate the number of those that are simple SELECTs versus more complex queries. I'll bet that many of your requests use connections for a very short amount of time, while others take more time. You need to either estimate or observe that pattern (and you can only estimate right now, since you're only in the dev phase) and then plan the size of your connection pool based upon that. This is crude capacity planning. If each connection lasts 1 second (a long time) and uses a DB connection through the entire request-response cycle, then you'll need exactly 200 connections in your connection pool (plus a few extra for good measure). 200 connections to your database might get very heavy, especially for Oracle (which at least /used/ to be known for very very heavy server-side connection memory requirements -- the db server, not the app server). Hope that helps, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGVDV19CaO5/Lv0PARAkEPAJ9UlPFD76jlZcTwEUr4Hf4jQXQj0gCfUzM3 ZE3Nb1DdqEh44WPc5l4EoZ8= =60Zz -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling How To ?
Hi Christropher .. Yes this is peek load actualy .. The requests are through SMS's which is forwarded by kannel server to my application . actually we are in development phase and we are testing it as per client specifications. So this was the load client specified ... i had set the max limit of my pool to 100 ... that may be the problem . i wud go and increase it now... Thanx Christopher Schultz-2 wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Jasdeep, > > jasdeep wrote: >> 2. Configuring Jboss's Internal Container Level Connection pooling >> simply >> creating the datasources > > This is the right way to do things. > >> The application works OK with Second method but When it is being hit with >> 200 request/second The pool gets [exhausted]. > > 200 requests per second is a /lot/ of traffic (8 million requests per > month, if that load is sustained). Is this a peak load, or a steady load? > > Does your pool become permanently exhausted? Or, do you have some users > who get exceptions (cannot get connection after timeout) and others who > get through. If the load drops off, is your pool still exhausted? If > that's the case, then you have a connection leak in your application. > > With heavy load, usually individual requests fail, but the server is > still healthy. You might run out of memory, but you can avoid that by > configuring your server to accept only a certain number of requests and > refusing the rest. > > How long is your connection pool timeout (the amount of time a thread > will wait for a connection before giving up). Perhaps you have to > increase that timeout. You could also increase the number of connections > in your pool. How many do you have in there, now? > > The last option is to buy more hardware. If you really are getting 200 > requests/sec, then you probably need some more hardware for your > application. > >> i am unable to decide which approach i should be using as my application >> can receive large no. of requests around 1000/sec ? > > Geez... I hope that's /peak/ load. Do you have to handle 1000 > requests/sec or 1000 simultaneous users? > > - -chris > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.7 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGUv4G9CaO5/Lv0PARAvZNAJ9+S6+Oyl5cEyFoxkgCmijHkJBJXgCgrzhP > lSigTUYwfyzbIkiEfBLT3Qw= > =ncCh > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Connection-Pooling--How-To---tf3796605.html#a10757338 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling How To ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jasdeep, jasdeep wrote: > 2. Configuring Jboss's Internal Container Level Connection pooling simply > creating the datasources This is the right way to do things. > The application works OK with Second method but When it is being hit with > 200 request/second The pool gets [exhausted]. 200 requests per second is a /lot/ of traffic (8 million requests per month, if that load is sustained). Is this a peak load, or a steady load? Does your pool become permanently exhausted? Or, do you have some users who get exceptions (cannot get connection after timeout) and others who get through. If the load drops off, is your pool still exhausted? If that's the case, then you have a connection leak in your application. With heavy load, usually individual requests fail, but the server is still healthy. You might run out of memory, but you can avoid that by configuring your server to accept only a certain number of requests and refusing the rest. How long is your connection pool timeout (the amount of time a thread will wait for a connection before giving up). Perhaps you have to increase that timeout. You could also increase the number of connections in your pool. How many do you have in there, now? The last option is to buy more hardware. If you really are getting 200 requests/sec, then you probably need some more hardware for your application. > i am unable to decide which approach i should be using as my application > can receive large no. of requests around 1000/sec ? Geez... I hope that's /peak/ load. Do you have to handle 1000 requests/sec or 1000 simultaneous users? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGUv4G9CaO5/Lv0PARAvZNAJ9+S6+Oyl5cEyFoxkgCmijHkJBJXgCgrzhP lSigTUYwfyzbIkiEfBLT3Qw= =ncCh -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection Pooling in Struts
Hi, Struts way (not good) Connection pooling is not available in latest version of struts 1 and struts 2. So if you upgrade your application to latest struts then you will be in trouble. Server (JNDI) very good All application servers provide it now. All applications can share it and change is at one place. No need to change anything related to DB connection in your application when upgrading to new version of struts / or moving to Different MVC framework (spring)... Regards Guru -Original Message- From: Saravanan Vijayappan [mailto:[EMAIL PROTECTED] Sent: 22 May 2007 10:18 To: struts user Subject: Connection Pooling in Struts Hi To set up connection pooling in struts which is the recommended way whether and please explain the benifts 1) Configure through struts-config 2) Configure through Server (like in tomcat data-source configuration) Thanks & Regards, Saravanan Vijayappan, +91 9448833571. Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545433 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling With Struts
Tomcat can provide a connection pool, you just have to configure the pool and look up the resource in your application. The details can be found here : http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Tushar Agrawal wrote: Hi Freinds, I am using struts-config default connection pooling with mysql. In future we may migrate to Oracle or SQL Server 2000 . Can you please tell me the best way of implementing connection pooling in struts with database as MySQL and Oracle 9i. Thanks Tushar Agrawal - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection Pooling With Struts
Hibernate (it has a Struts plugIn) can set those up automatically for you and connect to both using the same API. http://www.hibernate.org Regards, David -Original Message- From: Tushar Agrawal [mailto:[EMAIL PROTECTED] Sent: Thursday, November 04, 2004 11:08 PM To: Struts Mailing List Subject: Connection Pooling With Struts Hi Freinds, I am using struts-config default connection pooling with mysql. In future we may migrate to Oracle or SQL Server 2000 . Can you please tell me the best way of implementing connection pooling in struts with database as MySQL and Oracle 9i. Thanks Tushar Agrawal - Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com/a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection pooling problem
I have 4 excellent questions for you, of which #1 could be of EXTREME importance to you... 1. Have you changed your password YET since you posted all of your JDBC oracle details in the below message? 2. Have you logged into your Oracle database on the host chd4.sbc.com and verified that the connection pool is logged in and working under the username "scott" ? 3. Are you sure you are calling it correctly from line 49, the execute method of the Action class CalculationsReportAction (As listed below in your included error messages) ? I see the com.sbc.ssbilling.database..etc. (line 63) has trouble with what it was given so perhaps you're setting something up incorrectly. 4. Have you logged or echo printed our the JDNI resource jdbc.myoracle exists and then logged/echo-printed the class using, say... object.getClass() ? Regards, David -Original Message- From: LINGALA, AMARESHWAR G (SBCSI) [mailto:[EMAIL PROTECTED] Sent: Thursday, September 16, 2004 2:08 PM To: Struts Users Mailing List Subject: Connection pooling problem > Hi, > I am trying to set-up Connection pooling for my web application, > I have made the following modifications to my server.xml file. > > > > > > > > > > > >className="org.apache.catalina.mbeans.ServerLifecycleListener" > debug="0"/> >className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener > " > debug="0"/> > > > > > > value="30"/> > > >type="org.apache.catalina.UserDatabase" >description="User database that can be updated and saved"> > > > > factory > > org.apache.catalina.users.MemoryUserDatabaseFactory > > > pathname > conf/tomcat-users.xml > > > > > type="javax.sql.DataSource"/> > > > > factory > > org.apache.commons.dbcp.BasicDataSourceFactory > > > driverClassName > oracle.jdbc.driver.OracleDriver > > > url > > > > jdbc:oracle:thin:@chd4.sbc.com:1521:ostl411 > > > username > scott > > > password > tiger > > > maxActive > 20 > > > maxIdle > 10 > > > maxWait > -1 > > > > > > > > > > > > > > > maxThreads="150" minSpareThreads="25" > maxSpareThreads="75" >enableLookups="false" redirectPort="8443" > acceptCount="100" >debug="0" connectionTimeout="2" >disableUploadTimeout="true" /> > > > > > > > > > enableLookups="false" redirectPort="8443" debug="0" >protocol="AJP/1.3" /> > > > > > > > > > > > > > > > > > prefix="catalina_log." suffix=".txt" > timestamp="true"/> > > > > > debug="0" resourceName="UserDatabase"/> > > > > > > > > > > > > > > unpackWARs="true" autoDeploy="true" >xmlValidation="false" xmlNamespaceAware="false"> > > > > > > > > > > > > > > > > directory="logs" prefix="localhost_log." > suffix=".txt" > timestamp="true"/> > > > > > > > > > > But whenever I try to access the database I get the following error. > > > org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver > of class '' for connect URL 'null' > at > org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSour > ce.java:780) > at > org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource. > java:540) > at > com.sbc.ssbilling.database.DBConnectionImpl.makeDBConnection(DBConnect > ionImpl.java:63) > at > com.sbc.ssbilling.calculation.action.CalculationsReportAction.execute( > CalculationsReportAction.java:49) > at > org.apache.struts.action.RequestProcessor.processActionPerform(Request > Processor.java:484) > at > org.apache.struts.action.RequestProcessor.process(RequestProcessor.jav > a:274) > at > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482 > ) > at > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli > cationFilterChain.java:237) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi > lterChain.java:157) > at > org.apache.catalina.co
RE: connection pooling
> -Original Message- > From: Jignesh Patel [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 17, 2004 7:18 AM > To: Struts Users Mailing List > Subject: RE: connection pooling > > > Suppose I will put following code in my struts-config.xml instead of > tomcat's server.xml will it work as per the expectation for abandoned > connection. > > > > > > > > No I don' think so... tomcat is managing the connection not struts. > > > > -Jignesh > On Mon, 2004-08-16 at 18:20, Jim Barrows wrote: > > > -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? > > > > > > > > > > > > > > > > > property="driverClassName" > > > value="org.postgresql.Driver" /> > > > > > property="url" > > > value="jdbc:postgresql://localhost/mydatabase" /> > > > > > property="username" > > > value="me" /> > > > > > http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasourc > e-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20 > Configurations > > 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
RE: connection pooling
Suppose I will put following code in my struts-config.xml instead of tomcat's server.xml will it work as per the expectation for abandoned connection. -Jignesh On Mon, 2004-08-16 at 18:20, Jim Barrows wrote: > > -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? > > > > > > > > > > > property="driverClassName" > > value="org.postgresql.Driver" /> > > > property="url" > > value="jdbc:postgresql://localhost/mydatabase" /> > > > 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
RE: connection pooling
> -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? > > > > >property="driverClassName" > value="org.postgresql.Driver" /> >property="url" > value="jdbc:postgresql://localhost/mydatabase" /> >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 > > > > > > >
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? . . . .. 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]
RE: connection pooling
Saurabh, If you want to do some kind of initialization when your server starts up, you can implement the org.apache.struts.action.PlugIn interface and override the init() method to do your initialization. Check Logon example application, org.apache.struts.webapp.example.memory.MemoryDatabasePlugIn.java for more details. Regards, Sridhar -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. 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]
Re: connection pooling
yeah, I am planning to use OJB for persistence. Thankx for your advice. regards saurabh On Mon, 2004-08-16 at 16:43, David Durham wrote: > Jim Barrows wrote: > > > 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: > > Additionally, Saurabh, have you considered using something like OJB or > Hibernate? > > http://db.apache.org/ojb/ > http://www.hibernate.org/ > > I understand that you have limited experience in this area > (persistence), but these tools can greatly simplify storing and > retrieving objects from a relational database. > > > - Dave > > > - > 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]
RE: connection pooling
> -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]
Re: connection pooling
Jim Barrows wrote: 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: Additionally, Saurabh, have you considered using something like OJB or Hibernate? http://db.apache.org/ojb/ http://www.hibernate.org/ I understand that you have limited experience in this area (persistence), but these tools can greatly simplify storing and retrieving objects from a relational database. - Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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). 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. 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]
RE: connection pooling
> -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]
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. regards saurabh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: connection pooling
> -Original Message- > From: David Durham [mailto:[EMAIL PROTECTED] > Sent: Monday, August 16, 2004 2:01 PM > To: Struts Users Mailing List > Subject: Re: connection pooling > > > Saurabh Bhatla wrote: > > > Now i want to > > know how to initialize the connection pool object and how > to pass that > > object to all Action classes. > > I think you want to look at a piece of technology called JNDI. > > Here's a link to Tomcat's JNDI Datasource How-To: > > >http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html And doing that with struts: http://struts.apache.org/userGuide/configuration.html#data-source_config Alhtough, I would suggest maybe using a DAO layer for convienence later on down the road when things change :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connection pooling
David Durham wrote: I think you want to look at a piece of technology called JNDI. Here's a link to Tomcat's JNDI Datasource How-To: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html Considering the list topic, I guess I should post this link instead: http://struts.apache.org/faqs/database.html - Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: connection pooling
Saurabh Bhatla wrote: Now i want to know how to initialize the connection pool object and how to pass that object to all Action classes. I think you want to look at a piece of technology called JNDI. Here's a link to Tomcat's JNDI Datasource How-To: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html - Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling
Check http://jakarta.apache.org/commons/dbcp/configuration.html 's abandanded something parameters. I am not sure about how to apply this to Struts Datasource. I've just replaced Struts Datasouce with tomcat JNDI datasource with DBCP. to decouple Struts and DAOs. Masashi At 12:55 04/06/09 +0530, you wrote: Thanks for your attention. "Abandand connection management" can you give more details on how to do this. Masashi Nakane wrote: > And if you have a chance to try DBCP , Abandand connection management > function will tell you exactly where the unclosed connections are . You > will love this. > > Masashi > > At 23:33 04/06/08 -0700, you wrote: > >"And Some other guy says the set the max number of connectons to 1." > > > >Yes this is another good way, thank you for bringing that up. I had a > >fairly big app that was throwing away connections and when I set the > >max connections to 1 it became almost immediately aparent where the > >problem was. > > > >Good suggestion Masashi. > > > >- > >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]
Re: Connection Pooling
Thanks for your attention. "Abandand connection management" can you give more details on how to do this. Masashi Nakane wrote: > And if you have a chance to try DBCP , Abandand connection management > function will tell you exactly where the unclosed connections are . You > will love this. > > Masashi > > At 23:33 04/06/08 -0700, you wrote: > >"And Some other guy says the set the max number of connectons to 1." > > > >Yes this is another good way, thank you for bringing that up. I had a > >fairly big app that was throwing away connections and when I set the > >max connections to 1 it became almost immediately aparent where the > >problem was. > > > >Good suggestion Masashi. > > > >- > >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]
Re: Connection Pooling
Thanks for the response. I am using the "getConnection(request)" method to get the connection and then "connection.close()" to close the connection. "getConnection()" and "close()" both are in library files provided by struts (DBCP). Therefore it is difficult to put the counter in these methods. Any idea how can we put the counters in these methods? Or there is any way in which if i increase the DEBUG level and investigate the log file generated by Tomcat (catalina.out) Riyad Kalla wrote: > This may seem to simplistic, but you could do a search for whichever > method you call to open a connection and then do a search for > connection.close() (or whatever you named the variable) and see if the > numbers add up... if they don't, this might help you narrow down which > file the two aren't syncronous with eachother. > > Like I said though, this is the brute-force approach, I don't know a > 'good' way to do this off hand. > > On Wed, 09 Jun 2004 11:14:40 +0530, Shailender Jain > <[EMAIL PROTECTED]> wrote: > > > > I have fished developing the application using Struts and Tomcat 5.0.16 > > as server. > > > > We used the Connection Pooling provided by Struts (DBCP) > > > > After the development we have realized that somewhere in the application > > the connection is not > > getting closed. Due to this the application is getting hang very > > frequently. We have actually assumed that the application gets hang due > > to > > this reason only. > > > > Is there any way to DEBUG where in the application where the connection > > is not getting closed. > > > > Regards > > Shailender Jain > > > > - > > 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]
Re: Connection Pooling
And if you have a chance to try DBCP , Abandand connection management function will tell you exactly where the unclosed connections are . You will love this. Masashi At 23:33 04/06/08 -0700, you wrote: "And Some other guy says the set the max number of connectons to 1." Yes this is another good way, thank you for bringing that up. I had a fairly big app that was throwing away connections and when I set the max connections to 1 it became almost immediately aparent where the problem was. Good suggestion Masashi. - 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]
Re: Connection Pooling
"And Some other guy says the set the max number of connectons to 1." Yes this is another good way, thank you for bringing that up. I had a fairly big app that was throwing away connections and when I set the max connections to 1 it became almost immediately aparent where the problem was. Good suggestion Masashi. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling
I'm using Oracle and when I meet that situation, i check the DB session (v$session) and operate GUI . When number of DB sessions increase, that is the timing . And Some other guy says the set the max number of connectons to 1. hope this help At 22:49 04/06/08 -0700, you wrote: This may seem to simplistic, but you could do a search for whichever method you call to open a connection and then do a search for connection.close() (or whatever you named the variable) and see if the numbers add up... if they don't, this might help you narrow down which file the two aren't syncronous with eachother. Like I said though, this is the brute-force approach, I don't know a 'good' way to do this off hand. On Wed, 09 Jun 2004 11:14:40 +0530, Shailender Jain <[EMAIL PROTECTED]> wrote: > > I have fished developing the application using Struts and Tomcat 5.0.16 > as server. > > We used the Connection Pooling provided by Struts (DBCP) > > After the development we have realized that somewhere in the application > the connection is not > getting closed. Due to this the application is getting hang very > frequently. We have actually assumed that the application gets hang due > to > this reason only. > > Is there any way to DEBUG where in the application where the connection > is not getting closed. > > Regards > Shailender Jain > > - > 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]
Re: Connection Pooling
This may seem to simplistic, but you could do a search for whichever method you call to open a connection and then do a search for connection.close() (or whatever you named the variable) and see if the numbers add up... if they don't, this might help you narrow down which file the two aren't syncronous with eachother. Like I said though, this is the brute-force approach, I don't know a 'good' way to do this off hand. On Wed, 09 Jun 2004 11:14:40 +0530, Shailender Jain <[EMAIL PROTECTED]> wrote: > > I have fished developing the application using Struts and Tomcat 5.0.16 > as server. > > We used the Connection Pooling provided by Struts (DBCP) > > After the development we have realized that somewhere in the application > the connection is not > getting closed. Due to this the application is getting hang very > frequently. We have actually assumed that the application gets hang due > to > this reason only. > > Is there any way to DEBUG where in the application where the connection > is not getting closed. > > Regards > Shailender Jain > > - > 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]
Re: connection pooling
If 5 users are simultaneously using the database connections then you need to create more connections. Brati Sankar Ghosh Tata Consultancy Services Mailto: [EMAIL PROTECTED] Website: http://www.tcs.com Lokanath <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 05/20/2004 10:11 AM Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To Struts Users Mailing List <[EMAIL PROTECTED]> cc Subject connection pooling hi all i have a doubt over connection pooling.When 5 users are using a project in struts and if i have defined the maximumnumber of connection to 4 .Then how many connection will be estblished.What i mean to say is how many visible connection will be there in mysqlprocess lokanath -Original Message- From: Struts Users Mailing List [mailto:[EMAIL PROTECTED] Sent: Thursday, May 20, 2004 4:19 AM To: [EMAIL PROTECTED] Subject: Multiple nested Hashmaps. Limit? I am running into a problem with multiple Mapped nested properties When I use the following lines to access the Value form my dynaValueObj Object I get this error <% String value="dynaTableObj.dynaRowObjs("+rowNm+").dynaValueObjs("+key+").dynaCo lumnValue"; %> [ServletException in:/WEB-INF/src/jsp/dyna/dynaTableData.jsp] Null property value for 'dynaValueObjs(1)'' After tracing I found that it is not calling getDynaValueObjs(String xx) but calling getDynaValueObjs(). Is there a limitation on how many map-backed properties you can reference? Thanks Randy Shelley [EMAIL PROTECTED] -- Dyna Table Form Bean public class DynaTableDataForm extends ActionForm { private DynaTableObj dynaTableObj = null; public DynaTableObj getDynaTableObj () { if (this.dynaTableObj==null) { this.dynaTableObj = new DynaTableObj(); } return this.dynaTableObj; } public void setDynaTableObj (DynaTableObj dynaTableObj) { this.dynaTableObj = dynaTableObj; } } Dyna Table Object public class DynaTableObj { private LinkedHashMap dynaColumnObjs = null; public DynaTableObj() {} public void setDynaColumnObjs(LinkedHashMap dynaColumnObjs) { this.dynaColumnObjs = dynaColumnObjs; } public LinkedHashMap getDynaColumnObjs() { return this.dynaColumnObjs; } public Object getDynaColumnObjs(String dynaColumnId) { if (dynaColumnObjs==null) { this.dynaColumnObjs = new LinkedHashMap(); this.dynaColumnObjs.put(dynaColumnId,new DynaColumnObj()); } else if (this.dynaColumnObjs.get(dynaColumnId)==null) { this.dynaColumnObjs.put(dynaColumnId,new DynaColumnObj()); } return this.dynaColumnObjs.get(dynaColumnId); } public void setDynaColumnObjs(String dynaColumnId,Object dynaColumnObj) { if (dynaColumnObjs==null) { this.dynaColumnObjs = new LinkedHashMap(); } this.dynaColumnObjs.put(dynaColumnId,dynaColumnObj); } } -- Dyna Row Object public class DynaRowObj { private LinkedHashMap dynaValueObjs = null; public DynaRowObj() {} public void setDynaValueObjs(LinkedHashMap dynaColumnObjs) { this.dynaValueObjs = dynaValueObjs; } public LinkedHashMap getDynaValueObjs() { return this.dynaValueObjs; } public Object getDynaValueObjs(String dynaColumnId) { if (dynaValueObjs==null) { this.dynaValueObjs = new LinkedHashMap(); this.dynaValueObjs.put(dynaColumnId,new DynaValueObj()); } else if (this.dynaValueObjs.get(dynaColumnId)==null) { this.dynaValueObjs.put(dynaColumnId,new DynaColumnObj()); } return this.dynaValueObjs.get(dynaColumnId); } public void setDynaValueObjs(String dynaColumnId,Object dynaValueObj) { if (dynaValueObjs==null) { this.dynaValueObjs = new LinkedHashMap(); } this.dynaValueObjs.put(dynaColumnId,dynaValueObj); } } - Dyna Value Object package rshelley.timesheet.util; public class DynaValueObj { private String dynaColumnValue = null; public DynaValueObj() { } public void setDynaColumnValue(String dynaColumnValue) { this.dynaColumnValue = dynaColumnValue; } public String getDynaColumnValue() { return this.dynaColumnValue; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ForwardSourceID:NT9596 DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to Tata Consultancy Services. It must not be printed, read, copied, disclosed, forwarded, distributed or used (in wh
Re: connection pooling
If your pool max is 4, then you will see 4 and your 5th user will wait until someone returns their connection to the pool. Lokanath wrote: hi all i have a doubt over connection pooling.When 5 users are using a project in struts and if i have defined the maximumnumber of connection to 4 .Then how many connection will be estblished.What i mean to say is how many visible connection will be there in mysqlprocess lokanath -Original Message- From: Struts Users Mailing List [mailto:[EMAIL PROTECTED] Sent: Thursday, May 20, 2004 4:19 AM To: [EMAIL PROTECTED] Subject: Multiple nested Hashmaps. Limit? I am running into a problem with multiple Mapped nested properties When I use the following lines to access the Value form my dynaValueObj Object I get this error <% String value="dynaTableObj.dynaRowObjs("+rowNm+").dynaValueObjs("+key+").dynaCo lumnValue"; %> [ServletException in:/WEB-INF/src/jsp/dyna/dynaTableData.jsp] Null property value for 'dynaValueObjs(1)'' After tracing I found that it is not calling getDynaValueObjs(String xx) but calling getDynaValueObjs(). Is there a limitation on how many map-backed properties you can reference? Thanks Randy Shelley [EMAIL PROTECTED] -- Dyna Table Form Bean public class DynaTableDataForm extends ActionForm { private DynaTableObj dynaTableObj = null; public DynaTableObj getDynaTableObj () { if (this.dynaTableObj==null) { this.dynaTableObj = new DynaTableObj(); } return this.dynaTableObj; } public void setDynaTableObj (DynaTableObj dynaTableObj) { this.dynaTableObj = dynaTableObj; } } Dyna Table Object public class DynaTableObj { private LinkedHashMap dynaColumnObjs = null; public DynaTableObj() {} public void setDynaColumnObjs(LinkedHashMap dynaColumnObjs) { this.dynaColumnObjs = dynaColumnObjs; } public LinkedHashMap getDynaColumnObjs() { return this.dynaColumnObjs; } public Object getDynaColumnObjs(String dynaColumnId) { if (dynaColumnObjs==null) { this.dynaColumnObjs = new LinkedHashMap(); this.dynaColumnObjs.put(dynaColumnId,new DynaColumnObj()); } else if (this.dynaColumnObjs.get(dynaColumnId)==null) { this.dynaColumnObjs.put(dynaColumnId,new DynaColumnObj()); } return this.dynaColumnObjs.get(dynaColumnId); } public void setDynaColumnObjs(String dynaColumnId,Object dynaColumnObj) { if (dynaColumnObjs==null) { this.dynaColumnObjs = new LinkedHashMap(); } this.dynaColumnObjs.put(dynaColumnId,dynaColumnObj); } } -- Dyna Row Object public class DynaRowObj { private LinkedHashMap dynaValueObjs = null; public DynaRowObj() {} public void setDynaValueObjs(LinkedHashMap dynaColumnObjs) { this.dynaValueObjs = dynaValueObjs; } public LinkedHashMap getDynaValueObjs() { return this.dynaValueObjs; } public Object getDynaValueObjs(String dynaColumnId) { if (dynaValueObjs==null) { this.dynaValueObjs = new LinkedHashMap(); this.dynaValueObjs.put(dynaColumnId,new DynaValueObj()); } else if (this.dynaValueObjs.get(dynaColumnId)==null) { this.dynaValueObjs.put(dynaColumnId,new DynaColumnObj()); } return this.dynaValueObjs.get(dynaColumnId); } public void setDynaValueObjs(String dynaColumnId,Object dynaValueObj) { if (dynaValueObjs==null) { this.dynaValueObjs = new LinkedHashMap(); } this.dynaValueObjs.put(dynaColumnId,dynaValueObj); } } - Dyna Value Object package rshelley.timesheet.util; public class DynaValueObj { private String dynaColumnValue = null; public DynaValueObj() { } public void setDynaColumnValue(String dynaColumnValue) { this.dynaColumnValue = dynaColumnValue; } public String getDynaColumnValue() { return this.dynaColumnValue; } } - 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]
Re: Connection Pooling (How i use...)
Depends on your situation. If the SQL Exceptions are expected (i.e., a trigger could fail) then yes, you will want to catch that and send the message back to the user. However, if you are thinking JDBC is the way to go, you really should use something like iBATIS that hides this kind of stuff from you. Compared to the pile of code below, I would MUCH prefer writing this: List results; try{ results = sqlmap.executeQueryForList("myQuery", myParameters); }catch(SqlMapException e){ // deal with one exception type } No need to build your sql statement (just say NO to StringBuffer.append()), map parameters by numbers (YUCK), clean up resources, etc...and you end up with very tight readable application code. Larry >>> [EMAIL PROTECTED] 04/07/04 7:00 AM >>> So, are there implied catches in there for SQLException (I assume there are)? In the innermost try block, does the catch rethrow the SQLException so that it cascades to the outer blocks? Just trying to understand the model. Dean Hoover Larry Meadors wrote: >Yes. > >You really might want to consider a tool like iBATIS, but if you want to >do it yourself, here is the pattern: > >Connection c = null; >try{ > //get connection > try{ >// get statement >try{ > // get result set > // process result set >}finally{ > // close result set if not null >} > }finally{ >// close statement if not null > } >}finally{ > //close connection if not null >} > >Larry > >- >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]
Re: Connection Pooling (How i use...)
Hi all, Closing all ResultSets, Statements, Connection in the finally block fixed my app that stops crashing. Thanks everybody... Marcelo On Wed, 07 Apr 2004 09:00:16 -0400, "Dean A. Hoover" <[EMAIL PROTECTED]> escreveu: > De: "Dean A. Hoover" <[EMAIL PROTECTED]> > Data: Wed, 07 Apr 2004 09:00:16 -0400 > Para: Struts Users Mailing List <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling (How i use...) > > So, are there implied catches in there for SQLException (I assume there > are)? > In the innermost try block, does the catch rethrow the SQLException so that > it cascades to the outer blocks? > > Just trying to understand the model. > > Dean Hoover > > Larry Meadors wrote: > > >Yes. > > > >You really might want to consider a tool like iBATIS, but if you want to > >do it yourself, here is the pattern: > > > >Connection c = null; > >try{ > > //get connection > > try{ > >// get statement > >try{ > > // get result set > > // process result set > >}finally{ > > // close result set if not null > >} > > }finally{ > >// close statement if not null > > } > >}finally{ > > //close connection if not null > >} > > > >Larry > > > >- > >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]
Re: Connection Pooling (How i use...)
So, are there implied catches in there for SQLException (I assume there are)? In the innermost try block, does the catch rethrow the SQLException so that it cascades to the outer blocks? Just trying to understand the model. Dean Hoover Larry Meadors wrote: Yes. You really might want to consider a tool like iBATIS, but if you want to do it yourself, here is the pattern: Connection c = null; try{ //get connection try{ // get statement try{ // get result set // process result set }finally{ // close result set if not null } }finally{ // close statement if not null } }finally{ //close connection if not null } Larry - 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]
RE: Connection Pooling (How i use...)
See this Connection conn = null; try{ conn = ds.getConnection(); ...whatever you wish to do with conn.. catch(SQLException sqle) { action of exception } finally{ try{ if(nul != conn) conn.close(); } catch(SQLException sqle){ action of exception , may bejust ignore} } HTH Navjot Singh - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling (How i use...)
Uhh, yeah, I never did that, no, I just heard about it...yeah, that's it... ;-) >>> [EMAIL PROTECTED] 04/06/04 11:45 AM >>> *Quite* right: there was one time we had set the autoCommit on the connection object to false, forgotten to change it back before releasing it to the pool andwell,all I can say is we spent some "interesting" hours trying to debug that one! Geeta Larry Meadors wrote: > Yes. > > So be careful if you tweak the connection (like changing transaction > isolation, etc) because that connection may be used elsewhere, and your > change will persist. :) > > Larry > > >>> [EMAIL PROTECTED] 04/06/04 11:17 AM >>> > What happens when i do conn.close()? does it go back to the pool? > > - > 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]
Re: Connection Pooling - Monitor
Richard, I am already setting autoReconnect=true. I just want to know if exists any method that returns the # of opened connections are in the pool. Thanks. On Tue, 6 Apr 2004 10:54:06 -0700 (PDT), Richard Yee <[EMAIL PROTECTED]> escreveu: > De: Richard Yee <[EMAIL PROTECTED]> > Data: Tue, 6 Apr 2004 10:54:06 -0700 (PDT) > Para: Struts Users Mailing List <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling - Monitor > > Marcelo, > The # of connections is determined by the value you > set when you defined your datasource. What is the URL > that you are using? You should set autoReconnect=true > in the URL. > > -Richard > > > > --- Marcelo Epstein <[EMAIL PROTECTED]> wrote: > > > > Is it possible to know how many connection are in > > the pool ? Is there any monitor available? > > > > > > On Tue, 6 Apr 2004 14:15:34 -0300, "Marcelo > > Epstein" <[EMAIL PROTECTED]> escreveu: > > > > > De: "Marcelo Epstein" <[EMAIL PROTECTED]> > > > Data: Tue, 6 Apr 2004 14:15:34 -0300 > > > Para: "Struts Users Mailing List" > > <[EMAIL PROTECTED]> > > > Assunto: Re: Connection Pooling (How i use...) > > > > > > Now I am closing the connection in the finally > > block. > > > The exemple provided by: > > > > > > http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html > > > doesn´t do that: > > > package foo; > > > > > > import javax.naming.*; > > > import javax.sql.*; > > > import java.sql.*; > > > > > > public class DBTest { > > > > > > String foo = "Not Connected"; > > > int bar = -1; > > > > > > public void init() { > > > try{ > > > Context ctx = new InitialContext(); > > > if(ctx == null ) > > > throw new Exception("Boom - No > > Context"); > > > > > > DataSource ds = > > > (DataSource)ctx.lookup( > > >"java:comp/env/jdbc/TestDB"); > > > > > > if (ds != null) { > > > Connection conn = ds.getConnection(); > > > > > > if(conn != null) { > > > foo = "Got Connection > > "+conn.toString(); > > > Statement stmt = > > conn.createStatement(); > > > ResultSet rst = > > > stmt.executeQuery( > > > "select id, foo, bar from > > testdata"); > > > if(rst.next()) { > > >foo=rst.getString(2); > > >bar=rst.getInt(3); > > > } > > > conn.close(); > > > } > > > } > > > }catch(Exception e) { > > > e.printStackTrace(); > > > } > > > } > > > > > > public String getFoo() { return foo; } > > > public int getBar() { return bar;} > > > } > > > > > > > > > > > > > > > On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani" > > <[EMAIL PROTECTED]> escreveu: > > > > > > > De: "Geeta Ramani" <[EMAIL PROTECTED]> > > > > Data: Tue, 06 Apr 2004 12:50:29 -0400 > > > > Para: Struts Users Mailing List > > <[EMAIL PROTECTED]> > > > > Assunto: Re: Connection Pooling (How i use...) > > > > > > > > This your problem: closing the connection in > > your try block. Move it to a finally block.. > > > > > > > > Marcelo Epstein wrote: > > > > > > > > > I use the pool like this: (IS IT WRONG??) I > > think the connection is being closed.. > > > > > > > > > > try { > > > > > Context ctx = new InitialContext(); > > > > > if (ctx == null) > > > > > throw new Exception("Boom - No > > Context"); > > > > > > > > > > DataSource ds = (DataSource) > > ctx.lookup("java:comp/env/jdbc/EasyDB"); > > > > > > > > > > if (ds != null) { > > > > > Connection conn = > > ds.getConnection(); > > > > > if (conn != null) { > > > > > Statement stmt = > >
Re: Connection Pooling - Monitor
Marcelo, The # of connections is determined by the value you set when you defined your datasource. What is the URL that you are using? You should set autoReconnect=true in the URL. -Richard --- Marcelo Epstein <[EMAIL PROTECTED]> wrote: > > Is it possible to know how many connection are in > the pool ? Is there any monitor available? > > > On Tue, 6 Apr 2004 14:15:34 -0300, "Marcelo > Epstein" <[EMAIL PROTECTED]> escreveu: > > > De: "Marcelo Epstein" <[EMAIL PROTECTED]> > > Data: Tue, 6 Apr 2004 14:15:34 -0300 > > Para: "Struts Users Mailing List" > <[EMAIL PROTECTED]> > > Assunto: Re: Connection Pooling (How i use...) > > > > Now I am closing the connection in the finally > block. > > The exemple provided by: > > > http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html > > doesn´t do that: > > package foo; > > > > import javax.naming.*; > > import javax.sql.*; > > import java.sql.*; > > > > public class DBTest { > > > > String foo = "Not Connected"; > > int bar = -1; > > > > public void init() { > > try{ > > Context ctx = new InitialContext(); > > if(ctx == null ) > > throw new Exception("Boom - No > Context"); > > > > DataSource ds = > > (DataSource)ctx.lookup( > >"java:comp/env/jdbc/TestDB"); > > > > if (ds != null) { > > Connection conn = ds.getConnection(); > > > > if(conn != null) { > > foo = "Got Connection > "+conn.toString(); > > Statement stmt = > conn.createStatement(); > > ResultSet rst = > > stmt.executeQuery( > > "select id, foo, bar from > testdata"); > > if(rst.next()) { > >foo=rst.getString(2); > >bar=rst.getInt(3); > > } > > conn.close(); > > } > > } > > }catch(Exception e) { > > e.printStackTrace(); > > } > > } > > > > public String getFoo() { return foo; } > > public int getBar() { return bar;} > > } > > > > > > > > > > On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani" > <[EMAIL PROTECTED]> escreveu: > > > > > De: "Geeta Ramani" <[EMAIL PROTECTED]> > > > Data: Tue, 06 Apr 2004 12:50:29 -0400 > > > Para: Struts Users Mailing List > <[EMAIL PROTECTED]> > > > Assunto: Re: Connection Pooling (How i use...) > > > > > > This your problem: closing the connection in > your try block. Move it to a finally block.. > > > > > > Marcelo Epstein wrote: > > > > > > > I use the pool like this: (IS IT WRONG??) I > think the connection is being closed.. > > > > > > > > try { > > > > Context ctx = new InitialContext(); > > > > if (ctx == null) > > > > throw new Exception("Boom - No > Context"); > > > > > > > > DataSource ds = (DataSource) > ctx.lookup("java:comp/env/jdbc/EasyDB"); > > > > > > > > if (ds != null) { > > > > Connection conn = > ds.getConnection(); > > > > if (conn != null) { > > > > Statement stmt = > conn.createStatement(); > > > > String query ="Any > query"; > > > > ResultSet rs = > stmt.executeQuery(query); > > > > while (rs.next()) { > > > > >"Use ResulSet" > > > > > > > > } > > > > stmt.close(); > > > > conn.close(); > > > > } > > > > } > > > > } catch (Exception ex) { > > > > > System.out.println(ex.toString()); > > > > } > > > > > > > > On Tue, 06 Apr 2004 10:19:15 -0600, "Larry > Meadors" <[EMAIL PROTECTED]> escreveu: > > > > > > > > > De: "Larry Meadors" > <[EMAI
Re: Connection Pooling (How i use...)
*Quite* right: there was one time we had set the autoCommit on the connection object to false, forgotten to change it back before releasing it to the pool andwell,all I can say is we spent some "interesting" hours trying to debug that one! Geeta Larry Meadors wrote: > Yes. > > So be careful if you tweak the connection (like changing transaction > isolation, etc) because that connection may be used elsewhere, and your > change will persist. :) > > Larry > > >>> [EMAIL PROTECTED] 04/06/04 11:17 AM >>> > What happens when i do conn.close()? does it go back to the pool? > > - > 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]
Re: Connection Pooling (How i use...)
Oh yeah, that reminds me: Be careful not to double close your connections - with some implementations, that closes the pool. So do not close the connectionin the try *and* in the finally - do it *only* in the finally! Larry >>> [EMAIL PROTECTED] 04/06/04 11:25 AM >>> well, you are right...! What i meant was the main thing is to make sure that closing/.returning the connection to the pool is done in a "finally" block and not as part of the try block. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling (How i use...)
Ah, well, you didn't read the fine print: -->>Note: this code isn't anywhere near production ready - it's only supposed to be used as a simple test :-) Believe me, you should close connections/return them to the pool in a finally block if you want to avoid major problems.. As I said before, this issue was discussed in detail and in fcat the person with the initial question did a real nice write-up of her conclusions.. I think it will be well worth you while to read that thread.. Regards, Geeta Marcelo Epstein wrote: > Now I am closing the connection in the finally block. > The exemple provided by: > http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html > doesn´t do that: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling (How i use...)
I have yet to see a *good* example of how to do jdbc on the net. Most are very simple one-off "throws SQLException" examples that don't seem to take into consideration little things like stability and releasing resources. :) That is why I think tools like iBATIS are so powerful - you get all the power of JDBC without the pain. Larry >>> [EMAIL PROTECTED] 04/06/04 11:15 AM >>> Now I am closing the connection in the finally block. The exemple... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection Pooling (How i use...)
Yes. So be careful if you tweak the connection (like changing transaction isolation, etc) because that connection may be used elsewhere, and your change will persist. :) Larry >>> [EMAIL PROTECTED] 04/06/04 11:17 AM >>> What happens when i do conn.close()? does it go back to the pool? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling (How i use...)
well, you are right...! What i meant was the main thing is to make sure that closing/.returning the connection to the pool is done in a "finally" block and not as part of the try block. [EMAIL PROTECTED] wrote: > While using conn.close() does it return the connection to the pool?? > Its not a driver connection rather a data source connection...so waht happens when i > do conn.close()? > does it go back to the pool? > > -Original Message- > From: Geeta Ramani [mailto:[EMAIL PROTECTED] > Sent: Tue 4/6/2004 10:20 PM > To: Struts Users Mailing List > Cc: > Subject: Re: Connection Pooling (How i use...) > > > > This your problem: closing the connection in your try block. Move it to a > finally block.. > > Marcelo Epstein wrote: > > > I use the pool like this: (IS IT WRONG??) I think the connection is being > closed.. > > > > try { > > Context ctx = new InitialContext(); > > if (ctx == null) > > throw new Exception("Boom - No Context"); > > > > DataSource ds = (DataSource) > ctx.lookup("java:comp/env/jdbc/EasyDB"); > > > > if (ds != null) { > > Connection conn = ds.getConnection(); > > if (conn != null) { > > Statement stmt = conn.createStatement(); > > String query ="Any query"; > > ResultSet rs = stmt.executeQuery(query); > > while (rs.next()) { > > "Use > ResulSet" > > > > } > > stmt.close(); > > conn.close(); > > } > > } > > } catch (Exception ex) { > > System.out.println(ex.toString()); > > } > > > > On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> > escreveu: > > > > > De: "Larry Meadors" <[EMAIL PROTECTED]> > > > Data: Tue, 06 Apr 2004 10:19:15 -0600 > > > Para: <[EMAIL PROTECTED]> > > > Assunto: Re: Connection Pooling > > > > > > My bet is on a connection leak - you open one in a try block and don't > close it in the finally block. > > > > > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > > > Hi, > > > > > > I have just started using Connection Pooling in my app (Tomcat, Struts, > DBCP, Mysql) . > > > It woks for about 20 hours and stop working until tomcat restart. > > > > > > I get this exception: > > > > > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, > pool exhausted, cause: > > > java.util.NoSuchElementException: Timeout waiting for idle object > > > > > > I canÌ t fix it. Any advice?? > > > > > > Thanks in advance. > > > Marcelo > > > > > > > > > > > > - > > > 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] > > > > DISCLAIMER: > This message con
Re: Connection Pooling (How i use...)
Marcelo Could you do me the huge favor of keeping the version 3 drivers for another 20 hours but with the changes you've made (finally block stuff).. And tell us what happens in 20 or so hours. I'd be very interested in what you find. On 6 Apr 2004, at 19:15, Marcelo Epstein wrote: Now I am closing the connection in the finally block. The exemple provided by: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource- examples-howto.html doesn´t do that: package foo; import javax.naming.*; import javax.sql.*; import java.sql.*; public class DBTest { String foo = "Not Connected"; int bar = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) throw new Exception("Boom - No Context"); DataSource ds = (DataSource)ctx.lookup( "java:comp/env/jdbc/TestDB"); if (ds != null) { Connection conn = ds.getConnection(); if(conn != null) { foo = "Got Connection "+conn.toString(); Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery( "select id, foo, bar from testdata"); if(rst.next()) { foo=rst.getString(2); bar=rst.getInt(3); } conn.close(); } } }catch(Exception e) { e.printStackTrace(); } } public String getFoo() { return foo; } public int getBar() { return bar;} } On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani" <[EMAIL PROTECTED]> escreveu: De: "Geeta Ramani" <[EMAIL PROTECTED]> Data: Tue, 06 Apr 2004 12:50:29 -0400 Para: Struts Users Mailing List <[EMAIL PROTECTED]> Assunto: Re: Connection Pooling (How i use...) This your problem: closing the connection in your try block. Move it to a finally block.. Marcelo Epstein wrote: I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: De: "Larry Meadors" <[EMAIL PROTECTED]> Data: Tue, 06 Apr 2004 10:19:15 -0600 Para: <[EMAIL PROTECTED]> Assunto: Re: Connection Pooling My bet is on a connection leak - you open one in a try block and don't close it in the finally block. [EMAIL PROTECTED] 04/06/04 10:08 AM >>> Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I canÌ t fix it. Any advice?? Thanks in advance. Marcelo - 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]
Re: Connection Pooling (How i use...)
Now I am closing the connection in the finally block. The exemple provided by: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html doesn´t do that: package foo; import javax.naming.*; import javax.sql.*; import java.sql.*; public class DBTest { String foo = "Not Connected"; int bar = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) throw new Exception("Boom - No Context"); DataSource ds = (DataSource)ctx.lookup( "java:comp/env/jdbc/TestDB"); if (ds != null) { Connection conn = ds.getConnection(); if(conn != null) { foo = "Got Connection "+conn.toString(); Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery( "select id, foo, bar from testdata"); if(rst.next()) { foo=rst.getString(2); bar=rst.getInt(3); } conn.close(); } } }catch(Exception e) { e.printStackTrace(); } } public String getFoo() { return foo; } public int getBar() { return bar;} } On Tue, 06 Apr 2004 12:50:29 -0400, "Geeta Ramani" <[EMAIL PROTECTED]> escreveu: > De: "Geeta Ramani" <[EMAIL PROTECTED]> > Data: Tue, 06 Apr 2004 12:50:29 -0400 > Para: Struts Users Mailing List <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling (How i use...) > > This your problem: closing the connection in your try block. Move it to a finally > block.. > > Marcelo Epstein wrote: > > > I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. > > > > try { > > Context ctx = new InitialContext(); > > if (ctx == null) > > throw new Exception("Boom - No Context"); > > > > DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); > > > > if (ds != null) { > > Connection conn = ds.getConnection(); > > if (conn != null) { > > Statement stmt = conn.createStatement(); > > String query ="Any query"; > > ResultSet rs = stmt.executeQuery(query); > > while (rs.next()) { > > "Use ResulSet" > > > > } > > stmt.close(); > > conn.close(); > > } > > } > > } catch (Exception ex) { > > System.out.println(ex.toString()); > > } > > > > On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > > > > > De: "Larry Meadors" <[EMAIL PROTECTED]> > > > Data: Tue, 06 Apr 2004 10:19:15 -0600 > > > Para: <[EMAIL PROTECTED]> > > > Assunto: Re: Connection Pooling > > > > > > My bet is on a connection leak - you open one in a try block and don't close it > > > in the finally block. > > > > > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > > > Hi, > > > > > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, > > > Mysql) . > > > It woks for about 20 hours and stop working until tomcat restart. > > > > > > I get this exception: > > > > > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool > > > exhausted, cause: > > > java.util.NoSuchElementException: Timeout waiting for idle object > > > > > > I canÌ t fix it. Any advice?? > > > > > > Thanks in advance. > > > Marcelo > > > > > > > > > > > > - > > > 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]
RE: Connection Pooling (How i use...)
While using conn.close() does it return the connection to the pool?? Its not a driver connection rather a data source connection...so waht happens when i do conn.close()? does it go back to the pool? -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tue 4/6/2004 10:20 PM To: Struts Users Mailing List Cc: Subject: Re: Connection Pooling (How i use...) This your problem: closing the connection in your try block. Move it to a finally block.. Marcelo Epstein wrote: > I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. > > try { > Context ctx = new InitialContext(); > if (ctx == null) > throw new Exception("Boom - No Context"); > > DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); > > if (ds != null) { > Connection conn = ds.getConnection(); > if (conn != null) { > Statement stmt = conn.createStatement(); > String query ="Any query"; > ResultSet rs = stmt.executeQuery(query); > while (rs.next()) { > "Use ResulSet" > > } > stmt.close(); > conn.close(); > } > } > } catch (Exception ex) { > System.out.println(ex.toString()); > } > > On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > > > De: "Larry Meadors" <[EMAIL PROTECTED]> > > Data: Tue, 06 Apr 2004 10:19:15 -0600 > > Para: <[EMAIL PROTECTED]> > > Assunto: Re: Connection Pooling > > > > My bet is on a connection leak - you open one in a try block and don't close it in the finally block. > > > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > > Hi, > > > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . > > It woks for about 20 hours and stop working until tomcat restart. > > > > I get this exception: > > > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: > > java.util.NoSuchElementException: Timeout waiting for idle object > > > > I canà t fix it. Any advice?? > > > > Thanks in advance. > > Marcelo > > > > > > > > - > > 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] DISCLAIMER: This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted,corrupted,lost,destroyed,arrive late or incomplete or contain viruses.The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection Pooling (How i use...)
This your problem: closing the connection in your try block. Move it to a finally block.. Marcelo Epstein wrote: > I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. > > try { > Context ctx = new InitialContext(); > if (ctx == null) > throw new Exception("Boom - No Context"); > > DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); > > if (ds != null) { > Connection conn = ds.getConnection(); > if (conn != null) { > Statement stmt = conn.createStatement(); > String query ="Any query"; > ResultSet rs = stmt.executeQuery(query); > while (rs.next()) { > "Use ResulSet" > > } > stmt.close(); > conn.close(); > } > } > } catch (Exception ex) { > System.out.println(ex.toString()); > } > > On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > > > De: "Larry Meadors" <[EMAIL PROTECTED]> > > Data: Tue, 06 Apr 2004 10:19:15 -0600 > > Para: <[EMAIL PROTECTED]> > > Assunto: Re: Connection Pooling > > > > My bet is on a connection leak - you open one in a try block and don't close it in > > the finally block. > > > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > > Hi, > > > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, > > Mysql) . > > It woks for about 20 hours and stop working until tomcat restart. > > > > I get this exception: > > > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool > > exhausted, cause: > > java.util.NoSuchElementException: Timeout waiting for idle object > > > > I canÌ t fix it. Any advice?? > > > > Thanks in advance. > > Marcelo > > > > > > > > - > > 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]
Re: Connection Pooling (How i use...)
Looks like he is not re-inventing the wheel because he is already using DBCP. His question is just about how to use the pool properly. But if are we are talking about re-inventing the wheel, I would recommnd that you take a look a SQLMaps http://www.ibatis.com/common/sqlmaps.html. This takes away all of the code having to deal with the resources (the nested try/catch/finally blocks, the JNDI lookup, opening the connection, properly closing it, etc.) plus gives you addtional optional features like caching. Avinash Gangadharan wrote: Marcelo, If you do not want to reinvent the wheel and save some time, there is a great opensource DB Conn pool package available on SF. Check it out. It takes out all the extra efforts you need to put in and has great features and flexibilities. It's called proxool. http://proxool.sourceforge.net/ Avinash -Original Message- From: Marcelo Epstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 06, 2004 9:31 AM To: Struts Users Mailing List Subject: Re: Connection Pooling (How i use...) I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: De: "Larry Meadors" <[EMAIL PROTECTED]> Data: Tue, 06 Apr 2004 10:19:15 -0600 Para: <[EMAIL PROTECTED]> Assunto: Re: Connection Pooling My bet is on a connection leak - you open one in a try block and don't close it in the finally block. [EMAIL PROTECTED] 04/06/04 10:08 AM >>> Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I canÌ t fix it. Any advice?? Thanks in advance. Marcelo - 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]
Re: Connection Pooling (How i use...)
Yes. You really might want to consider a tool like iBATIS, but if you want to do it yourself, here is the pattern: Connection c = null; try{ //get connection try{ // get statement try{ // get result set // process result set }finally{ // close result set if not null } }finally{ // close statement if not null } }finally{ //close connection if not null } Larry - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connection Pooling (How i use...)
Marcelo, While what you are doing is technically correct, it is safer to place all of your closing statements in a finally block. This way they are guaranteed to run in the event of an exception being thrown. I have also found that you should always close everything ResultSets, Statements, PreparedStatements as well. Although the most of the API's I have read state that dependencies will be closed, I have run across several implementations that did not work that way. So I always close inner most objects to outermost (ResultSets, Statement/PreparedStatement, Connection in that order) and always in a finally block. Brian McClung Senior Programmer Belo Interactive -Original Message- From: Marcelo Epstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 06, 2004 11:31 AM To: Struts Users Mailing List Subject: Re: Connection Pooling (How i use...) I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > De: "Larry Meadors" <[EMAIL PROTECTED]> > Data: Tue, 06 Apr 2004 10:19:15 -0600 > Para: <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling > > My bet is on a connection leak - you open one in a try block and don't close it in the finally block. > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > Hi, > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . > It woks for about 20 hours and stop working until tomcat restart. > > I get this exception: > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: > java.util.NoSuchElementException: Timeout waiting for idle object > > I canÌ t fix it. Any advice?? > > Thanks in advance. > Marcelo > > > > - > 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]
Re: Connection Pooling
I had the same.. I ditched version 2 and haven't had any problems since. On 6 Apr 2004, at 18:34, Marcelo Epstein wrote: Mark, I am using Mysql Driver version 3. What´s the problem of this "stable" driver. ?? I will give a try version 2. But I really cant understand why.. Thanks... On Tue, 6 Apr 2004 18:20:29 +0200, Mark Lowe <[EMAIL PROTECTED]> escreveu: De: Mark Lowe <[EMAIL PROTECTED]> Data: Tue, 6 Apr 2004 18:20:29 +0200 Para: "Struts Users Mailing List" <[EMAIL PROTECTED]> Assunto: Re: Connection Pooling If your using the version 3 mysql driver don't.. Use version 2 and never look back. There also a ?autoReconnect=true parameter to pass through with the url, but i think thats bollocks or at least didn't work with version3 mysql drivers. On 6 Apr 2004, at 18:08, Marcelo Epstein wrote: Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I can´t fix it. Any advice?? Thanks in advance. Marcelo - 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]
RE: Connection Pooling (How i use...)
Marcelo, If you do not want to reinvent the wheel and save some time, there is a great opensource DB Conn pool package available on SF. Check it out. It takes out all the extra efforts you need to put in and has great features and flexibilities. It's called proxool. http://proxool.sourceforge.net/ Avinash -Original Message- From: Marcelo Epstein [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 06, 2004 9:31 AM To: Struts Users Mailing List Subject: Re: Connection Pooling (How i use...) I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > De: "Larry Meadors" <[EMAIL PROTECTED]> > Data: Tue, 06 Apr 2004 10:19:15 -0600 > Para: <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling > > My bet is on a connection leak - you open one in a try block and don't > close it in the finally block. > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > Hi, > > I have just started using Connection Pooling in my app (Tomcat, > Struts, DBCP, Mysql) . It woks for about 20 hours and stop working > until tomcat restart. > > I get this exception: > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, > pool exhausted, cause: > java.util.NoSuchElementException: Timeout waiting for idle object > > I canÌ t fix it. Any advice?? > > Thanks in advance. > Marcelo > > > > - > 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]
Re: Connection Pooling (How i use...)
Yes, you need to put the conn.close() in a finally, something like this Connection conn = null; try { ... conn = ds.getConnection(); ... } catch(Exception ex) { } finally { try { conn.close(); } catch(Exception ex) { System.err.println(ex); } } In your way, if there is an exception, the connection will not be closed, because the code will not reach the conn.close() statement. Marcelo Epstein wrote: I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: De: "Larry Meadors" <[EMAIL PROTECTED]> Data: Tue, 06 Apr 2004 10:19:15 -0600 Para: <[EMAIL PROTECTED]> Assunto: Re: Connection Pooling My bet is on a connection leak - you open one in a try block and don't close it in the finally block. [EMAIL PROTECTED] 04/06/04 10:08 AM >>> Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I canÌ t fix it. Any advice?? Thanks in advance. Marcelo - 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]
Re: Connection Pooling
Mark, I am using Mysql Driver version 3. What´s the problem of this "stable" driver. ?? I will give a try version 2. But I really cant understand why.. Thanks... On Tue, 6 Apr 2004 18:20:29 +0200, Mark Lowe <[EMAIL PROTECTED]> escreveu: > De: Mark Lowe <[EMAIL PROTECTED]> > Data: Tue, 6 Apr 2004 18:20:29 +0200 > Para: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling > > If your using the version 3 mysql driver don't.. Use version 2 and > never look back. > > There also a ?autoReconnect=true parameter to pass through with the > url, but i think thats bollocks or at least didn't work with version3 > mysql drivers. > > On 6 Apr 2004, at 18:08, Marcelo Epstein wrote: > > > Hi, > > > > I have just started using Connection Pooling in my app (Tomcat, > > Struts, DBCP, Mysql) . > > It woks for about 20 hours and stop working until tomcat restart. > > > > I get this exception: > > > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, > > pool exhausted, cause: > > java.util.NoSuchElementException: Timeout waiting for idle object > > > > I can´t fix it. Any advice?? > > > > Thanks in advance. > > Marcelo > > > > > > > > - > > 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]
Re: Connection Pooling (How i use...)
I use the pool like this: (IS IT WRONG??) I think the connection is being closed.. try { Context ctx = new InitialContext(); if (ctx == null) throw new Exception("Boom - No Context"); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/EasyDB"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { Statement stmt = conn.createStatement(); String query ="Any query"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { "Use ResulSet" } stmt.close(); conn.close(); } } } catch (Exception ex) { System.out.println(ex.toString()); } On Tue, 06 Apr 2004 10:19:15 -0600, "Larry Meadors" <[EMAIL PROTECTED]> escreveu: > De: "Larry Meadors" <[EMAIL PROTECTED]> > Data: Tue, 06 Apr 2004 10:19:15 -0600 > Para: <[EMAIL PROTECTED]> > Assunto: Re: Connection Pooling > > My bet is on a connection leak - you open one in a try block and don't close it in > the finally block. > > >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> > Hi, > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, > Mysql) . > It woks for about 20 hours and stop working until tomcat restart. > > I get this exception: > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, > cause: > java.util.NoSuchElementException: Timeout waiting for idle object > > I canÌ t fix it. Any advice?? > > Thanks in advance. > Marcelo > > > > - > 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]
Re: Connection Pooling
If your using the version 3 mysql driver don't.. Use version 2 and never look back. There also a ?autoReconnect=true parameter to pass through with the url, but i think thats bollocks or at least didn't work with version3 mysql drivers. On 6 Apr 2004, at 18:08, Marcelo Epstein wrote: Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I can´t fix it. Any advice?? Thanks in advance. Marcelo - 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]
Re: Connection Pooling
My bet is on a connection leak - you open one in a try block and don't close it in the finally block. >>> [EMAIL PROTECTED] 04/06/04 10:08 AM >>> Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I canÌ t fix it. Any advice?? Thanks in advance. Marcelo - 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]
RE: Connection Pooling
These are the main 2 reasons that come to me: (1) You are not "closing" the connection once you've finished using it. This signals the pool's manager when to re-assign that connection (i.e. you've finished, so it can be used by someone else). (2) Your connection pool is not big enough. HTH, Freddy. -Mensaje original- De: Marcelo Epstein [mailto:[EMAIL PROTECTED] Enviado el: martes, 06 de abril de 2004 18:09 Para: Struts Users Mailing List Asunto: Connection Pooling Hi, I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, Mysql) . It woks for about 20 hours and stop working until tomcat restart. I get this exception: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, cause: java.util.NoSuchElementException: Timeout waiting for idle object I can´t fix it. Any advice?? Thanks in advance. Marcelo - 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]
Re: Connection Pooling
Marcelo; You are probably exhausting all your connections in the pool. Make sure all your connections are returned back to the pool at the end of a "finally" block. That way the connection is returned to the pool regardless of whether your database work was a success or not. Also, while you are developing, keep the number of connections in the pool restricted to 1. That way you can easily verify that you are always returning connections back.. A while back a long discussion was held here relating to just this issue.. you may want to search the archives.. (let me know if you cant find the discussion..) Regards, Geeta Marcelo Epstein wrote: > Hi, > > I have just started using Connection Pooling in my app (Tomcat, Struts, DBCP, > Mysql) . > It woks for about 20 hours and stop working until tomcat restart. > > I get this exception: > > org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted, > cause: > java.util.NoSuchElementException: Timeout waiting for idle object > > I can´t fix it. Any advice?? > > Thanks in advance. > Marcelo > > - > 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]