You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johannes Tyve <Jo...@sgu.se> on 2003/06/03 11:22:13 UTC

List rows in a table using Beans instead of Recordset

Hi

I'm new to Struts and would like some directions.

I'm used to servlets, jsp, scriplets with recordset eg. 
ResultSet rs = stmt.executeQuerY("....");
while( rs.next() )
 { %>
        <%= rs.getString("...") %>
<%}

Now I store my data in a bean (loaded from a row in the database) and it 
works fine when I load, store and update one single row but how do I do 
when I have a list of rows?
I could load all my rows into a collection of beans but what if there are 
millions of rows? Using a recordset I can limit my selection to 10 records 
at a time and then move my database cursor forward or reverse to show the 
next /prev 10 records. How is this performed using Struts and beans?

Regards,
Johannes

OT: Re: List rows in a table using Beans instead of Recordset

Posted by Vic Cekvenich <vi...@baseBeans.com>.
This is OT for a frame  work, consider posting JDBC questions on 
comp.lang.java.databases or SQL SIGs, but...

Most people that use framework like Struts, use a DAO (like iBatis ... 
or Hibreante) and do not code at ResultSet level, else we would be using 
a servlet and not a framework.
Struts provides nothing for a DAO, a very nice feature, so you can pick 
anything you like (but picking nothing is not ideal). Look at above 2 
for starters.

For offsetting I use SELECT .... LIMIT 10 OFFSET 1, using a SQL command 
at the DAO level. From Struts you just want to track which OFFSET to 
pass to DAO.
(Yes, most DAOs do caching and flushing automatically). Also OT, using 
cursors is a bad SQL practice, but any SQL list will tell you that.

hth,

.V

Johannes Tyve wrote:

>Hi
>
>I'm new to Struts and would like some directions.
>
>I'm used to servlets, jsp, scriplets with recordset eg. 
>ResultSet rs = stmt.executeQuerY("....");
>while( rs.next() )
> { %>
>        <%= rs.getString("...") %>
><%}
>
>Now I store my data in a bean (loaded from a row in the database) and it 
>works fine when I load, store and update one single row but how do I do 
>when I have a list of rows?
>I could load all my rows into a collection of beans but what if there are 
>millions of rows? Using a recordset I can limit my selection to 10 records 
>at a time and then move my database cursor forward or reverse to show the 
>next /prev 10 records. How is this performed using Struts and beans?
>
>Regards,
>Johannes
>  
>

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a> and project recovery in North East.
Open Source <a href ="baseBeans.com">Content Management</a>  basicPortal sofware
Best practice<a href ="baseBeans.com">Struts Support</a> v.1.1 helper ScafflodingXPress




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org