struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "V. Cekvenich" <>
Subject Using data-source with ActionForm
Date Sun, 29 Sep 2002 03:02:45 GMT
Vincent, in response to:

(others asked related questions on JDBC / connection pool, closing, etc.)

You are right, you do not do it in a getter in a setter.
Mostly you have a bean. And even the bean delegates to DAO.
DAO handles the connection, etc.

A good practices is: a property has a getter/setter in a bean, and a 
bean has a DAO it delegates to.

You could have a DAO with a class/static initialize that gets the data 
I do not link philosophical answers so here is a  code sample, note use 
of static:

It uses DBCP from Jakarta commons connection pool with PostgreSQL from, a FREE full ANSI SQL compliant DB, but you get the point 
of how to use a static class initialize to get a handle to a data source 
so you can look up the data source once, and then just dish out connection.

Also I use rowset over resultset, which makes it very easy to close, and 
destroy, unlike resultset. (con.close,rs.close, stmnt.close, plus it 
loses data on a connection disconect)
Rowset also does not reduces need for GC generated by VO/DTO and 
collections, since a disconnected rowset has the values. I use an open 
source rowset from sourceforge called jxutil.

Also, at you can download for free a 350 page book a 
bit more advanced that talks about db quite a bit.


ps: A benefit of MVC is modular, hence each layer is unit testable, such 
as a bean that delegates to DAO interface, which above also enables.

ps2: Answer to what is the most popular hands on training class and who 
teaches it?

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message