Hello,

On Fri, 23 Mar 2001, Gerry Scheetz wrote:

> Date: Fri, 23 Mar 2001 10:25:35 -0500
> From: Gerry Scheetz <[EMAIL PROTECTED]>
> Reply-To: A mailing list about Java Server Pages specification and
      reference <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: MVC and Database Connection Pool
>
> I am developing a database application and am using a similar MVC
> design to that in a couple books I have. In those books they have a
> singleton class (a class in which there will only ever be one
> instance) that accesses the database to create JavaBeans, which are
> used to populate the JSP pages. These singleton classes also are used
> to update the database with information from those JavaBeans.
>

Sounds like Data Access Object pattern, correct?

> Now I am assuming you have more that one of these singleton classes in
> larger systems. Example, I am working on a billing inquiry system. So
> I have one singleton class for the CustomerBean and a different
> singleton class for the Invoice Bean. (I could be wrong in this
> assumption and there lies my problem.)

This is the way that JavaPet Store does it, so I guess that's the way to
go :)
If you are using Data Access Object pattern in conjunction with JavaBeans
(not EJBs) the migration to EJB is pretty easy.

> I would also like to use Database Connection Pooling. I would like to
> have one collection of connections that are used by all the singleton
> classes. I would also like to hide the fact that I am using a database

See com.sun.j2ee.blueprints.customer.order.ejb.OrderDAO and
com.sun.j2ee.blueprints.customer.order.ejb.OrderEJB for examples.
They acquire DataSource in DAO constructor and get a connection from the
DataSource in each db interaction and close it immediately.

> to every classes except the singleton classes. Right now I can not
> figure out how to use one common collection without defining it in my
> Controller/Servlet class and then instantiating all my singleton
> classes and telling them about the connection pool.

I have used a Controller servlet that initializes a Connection pool and
binds it into JNDI and all business JavaBeans use one Connection pool
wrapper class that fetches connections from JNDI connection pool. This
(wrapper) approach abstracts nicely the used connection pool
implementation away, so I'm able to replace it with DataSource or what
ever connection pooling mechanism. At the moment I'm using
http://poolman.sourceforge.net/ as a connection pool for my JavaBean apps.

>
> So what I am looking for is examples of class organizations of people
> using MVC and database connection pools. Also would be interested in
> other online examples or e-mail lists where I could get an answer to
> my question.
>

See Java Pet Store from http://java.sun.com and Struts Framework
http://jakarta.apache.org/struts/

Cheers,
Kare

> TIA,
>
> Gerry Scheetz
> Web Application Development
> Global Information Technology Division
> TRW - S&ITG
> Helena, Montana, USA
> [EMAIL PROTECTED]
> (406) 594-1878
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

--
Kare Nuorteva
http://www.kare.uklinux.net/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to