Обсуждение: Swing JTable and ResultSet TableModel (with big resultsets)

Поиск
Список
Период
Сортировка

Swing JTable and ResultSet TableModel (with big resultsets)

От
"Stefano B."
Дата:
Hi, I don't know if this is the right list for this question but I don't know where to ask...
 
I have a question about JTable and a ResultSet TableModel (using JDBC postgresql driver).
 
I have to develop a swing JTable application that gets the data from a ResultSetTableModel where the user can update the jtable data.
The problem is the following:
 
the JTable have to contain the whole data of the source database table. Currently I have defined a
 
a TYPE_SCROLL_SENSITIVE & CONCUR_UPDATABLE statement.
 
The problem is that when I execute the query the whole ResultSet is "downloaded" on the client side application (my jtable) and I could receive (with big resultsets) an "out of memory error"...
 
I have investigate about the possibility of load (in the client side) only a small subset of the resultset but with no luck. In the maling lists I see that the only way to load the resultset incrementally is to define a forward only resultset with autocommit off, and using setFetchSize(...). But this solution doesn't solve my problem because if the user scrolls the entire table, the whole resultset will be downloaded...
 
In my opinion, there is only one solution:
 
- create a small JTable "cache structure" and update the structure with "remote calls" to the server ...
in other words I have to define on the server side a "servlet environment" that queries the database, creates the resultset and gives to the jtable only the data subsets that it needs... (alternatively I could define an RMI client/server distribuited applications...)
 
This is my solution, somebody can help me?
Are there others solutions for my problem?
 
Thanks in advance,
    Stefano

Re: Swing JTable and ResultSet TableModel (with big resultsets)

От
John DeSoi
Дата:
On Oct 27, 2006, at 5:29 AM, Stefano B. wrote:

> I have investigate about the possibility of load (in the client
> side) only a small subset of the resultset but with no luck. In the
> maling lists I see that the only way to load the resultset
> incrementally is to define a forward only resultset with autocommit
> off, and using setFetchSize(...). But this solution doesn't solve
> my problem because if the user scrolls the entire table, the whole
> resultset will be downloaded...

I don't use JDBC so maybe I don't understand the limitations. But
PostgreSQL supports cursors that can be scanned forward and
backwards. Using FETCH you can just get the data you need for the
display. See the DECLARE documentation:

http://www.postgresql.org/docs/8.1/interactive/sql-declare.html





John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL