Say, in a web application (no EJB layer), for MVC model, the controller(filter or servlet) will delegate the requests to corresponding model, and the model will do the business, like getting the date from database, then, my question is:
Where should we keep the connection pool? in controller or in model.
If we keep the connection pool in controller, I think it might be easy to manage all the connection in one class(not sure). but we have to pass the connection reference to the model. this seems violating the isolation. [ March 20, 2007: Message edited by: damu liu ]
most servers will actually support connection pooling themselves. You should look into your particular servers details to find out how it is set up. Your web app would then access a connection via a JNDI lookup. Certainly you can do this in the Sun One webserver. I'm 99.9% certain that you can do it in tomcat by fiddling with the xml config files - though I've never done it.
Hope that helps,
author & internet detective
Originally posted by damu liu: Where should we keep the connection pool? in controller or in model.
Neither. You should keep it in the connection pool. If you server supports datasources, the server takes care of it as Daniel described. If not, you can use an open source connection pool like DBCP.
Either way, you request the connection from the pool in your data access code. It goes where you would have asked DriverManager for a connection if you weren't using pooling - in your data access class. While the connection pool is called from your model, technically it isn't in your model. And it certainly isn't in the controller - the controller should just be delegating requests.
Joined: Feb 26, 2003
thanks Daniel and Jeanne.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com