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.
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
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Nov 19, 2000
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 firstname.lastname@example.org and I would like to learn the example provided by you.