Hi Vicenrico,

Why don't you create a table with a pageable resultset by doing something 
like this:
Select title, release_date, rating (... or whatever columns you want to 
display, assuming you don't show all 30 columns in the table)
from movies
order by title
limit 50 offset 0

This will return the first 50 records that you load into your table.  Just 
remember to add the 'order by' clause, else your data might not be returned 
in the order you expect.  

Limit is the number of records on a page, and the Offset is the number of 
records to skip before returning results.

Now add buttons for First, Previous, Next and Last, that will move your 
offset (the current page) forward or backward.
So, if the user clicks Next, call the same query again, but use 50 for the 
offset, meaning it will skip the first 50 records and bring back the next 
50.  The first page will have an offset of 0, the second 50, third 100 etc.

Add logic to your table so that it knows what page its on.  



On Sunday, June 17, 2012 7:04:38 PM UTC+2, vicenrico wrote:
>
> Hello. As I'm a newbie, I would like to better learn use of databases.
> Which is the best method to load a database, supposing I have about 
> 4000-5000 rows that consist of 30 columns.
>
> I don't know if it's better to load "Select * from table" and load all the 
> objects into an array or it's better take row by row when constructing 
> table (jface tableviewer in my case) .
> I mean:
>
> Form1:
>
> select * from table
> arraylist<movie> moviesList=new arraylist<movie>
> iterate trough resultset filling movieslist
>
>
> OR
>
>
> Form2:
>
> With tableviewer whenever it needs to be redraw:
>
> tableviewer.setdata(xxx)
> load a movieobject from the table
> fill the item of the tableviewer.
>
>
> The problem with form1 is memory comsumption, and the problem with form2 
> is when the list must be redraw can call this method a lot of times.
>
> Do you know alternative ways of database loading. I know about chunks 
> loading but I don't like because I don't know methods to do the 
> replacement: less recent used, and so on...
>
> Sorry for the question, I know it's a very newbie question, but I'm 
> beginning and I don't know how real people load databases: all objects in a 
> list, or when needed by the table.
>
> Thanks!!!
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/C4KFI0REC0gJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to