• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Must Restart Tomcat to Aquire A Connection From The Pool

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I configured dbcp connection pool in Tomcat 4.1.18 server.xml file.
Here is an extract of it:

Everything works fine. But when our database server is restarted, I have to restart Tomcat
in order to aquire connection from the defined pool.
I wonder if there is a way to avoid restarting Tomcat when the database server is restarted.
I have added the parameters below to my pool config.

I recognize ,I've added that quite blindly.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Caroline,
The return address on the private email you sent me turned out to be my own address, so, since it's of fairly general interest, I'm pasting it below. Normally I'd put it in the Struts forum, but it's kind of connected to what you just asked, and I figured that you'd be more likely to see it here.
I'm out of practice on Struts Datasources, though I hope that before the week's out I'll be working on a project that uses them again. The original source code can be found under the "Get the code" hyperlink on the upper-right corner of the online version of the article at:
http://www.fawcette.com/javapro/2002_04/magazine/features/tholloway/
The demo site (which got eaten by the Slapper worm) was the identical code except that I'd put in footnotes at the bottom of each web page that displayed the source code for the Action Procedures, JSP's and the xonfig files.
The actual connection pool is defined at the top of the struts-config.xml file. The action processors call the FormBean load() and save() method to handle persistence (some people thing that persistence should be part of the Action processor itself, but I was thinking in EJB terms). The Form Bean load() and save() methods invoke the servlet.findDataSource() method to acquire a Connection from the connection pool.
A more recent project I did uses EJBs and the JBoss appserver. In this case, the EJBs and security system are also invoking JDBC. I think JBoss has its own connection pool management, so the struts-config.xml connection pool feature wasn't used, but I had to subclass the Struts ActionServlet in order to make the JBoss connection pool serve as a Struts connection pool. It wasn't hard, though I can't give any examples, since the machine with the source code for that project is currently offline. If you need it, let me know and I'll send a copy, though it might take about a week to get it.
Good luck!
Tim Holloway
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently, I employ Tomcat for my Struts project. Tomcat also has its own connection pool management.
People have suggested to separate db access layer from struts for easier debugging, faster testing. Therefore, I did not configure the connection pool in the struts-config.xml file.
Does it mean that I have to subclass the Struts ActionServlet for Tomcat serving as the connection pool? If it is the case, I do want to see your example.
I have a utility/helper class that specialized in creating a connection pool:

And the Connection object (conn) returned from this helper/utility class is to be accessed in model objects. Is this the way your example works? My e-mail address is jiapei_jen@yahoo.com and I would like to learn the example provided by you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic