On Fri, 14 Mar 2003, Robert McIntosh wrote:
> Date: Fri, 14 Mar 2003 09:38:50 -0600 > From: Robert McIntosh <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: Re: Data driven struts application > > Using a ResultSet directly is generally seen as bad practice. > > At a minimum you should probably use the ResultSetDynaClass then next in > line would be a RowSetDynaClass, then JavaBeans. As for the JavaBean > properties question, it would be easier to return a Collection of > JavaBeans where each bean represented each row in the resultset. > Note that using ResultSetDynaClass doesn't get you out of leaving the underlying ResultSet open (and the connection allocated from your connection pool), so it is still not the best choice for making data available to the view tier. It's primary value is exposing ResultSet data as DynaBeans for processing inside the business tier. For maximum efficiency, no data copying is done -- it essentially synthesizes a DynaBean for the current row (have a look at the sources if you want to see the world's strangest "Iterator" implementation :-). RowSetDynaClass, on the other hand, is quite useful for making data available to the view tier. It makes a copy of the data, so the underlying result set can be immediately closed, and the connection returned to the connection pool. And, because it again exposes DynaBeans, all the standard Struts tags can deal with it just like a collection of standard JavaBeans. The only downside is that the copying can be computationaly and/or memory-wise expensive, so be sure you don't try things like performing a million row query and then trying to make a RowSetDynaClass out of it. > ~Robert Craig McClanahan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]