• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Struts and Connection Pooling

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've frequently seen it stated that Struts provide database connection pooling. 'Mastering Jakarta Struts' says "As of 1.1, the DataSource implementation used by the Struts project models the Pooled implementation". However in all the examples I see (including in MJS) the connection is retrieved via the DataSource, used and then explicitly closed. It seems to me that if there's a pooling mechanism the connection should be freed (returned to the pool) and not closed. I think I must really be missing something and I haven't been able to find any good information on this topic.
Thanks,
Mars
 
Marcellus Tryk
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops - I didn't read far enough. 'Mastering Jakarta Struts' goes on to say:
In the normal definition of the Connection class, this method would close the connection to the database and thus render it useless for later processes, but because this Connection object is an instance of a wrapper object, the Connection is returned to the pool for later use, instead of actually being closed.
That certainly answers my question.
Thanks Mr. Goodwill!
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mars,
in my opinion one of my most efective refactorings of last week was to replace the connection pool of struts-config.xml with a own connection pooling management class separated from struts. I use http://www.bitmechanic.com/projects/jdbcpool/ (there might exist better ones. one could even use some object relational mapping tool).
It really helped to keep db access layer separated from struts. So I can put business logic in beans or other Java classes, let them access the database, test the business logic and then later build some struts-jsp/servlet stuff which accesses this business logic.
This leads to faster testing, better separation of logical layers, easier debugging if needed and maybe something I am still not aware of.
Any opinions?
..answering not asked questions
[ October 20, 2002: Message edited by: Axel Janssen ]
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I agree totally. Struts offers several features to accelerate development for simple projects, such as connection pooling, but IMO they can and should be dropped and replaced by more elegant and robust solutions for big projects.
Adam
 
Marcellus Tryk
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the insights - I'm going to pursue that.
Mars
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic