By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

JTable and RowSet

P: n/a
Hi fellows,

I was wondering if in the Java API there's a way to easily map a
disconnected RowSet to a JTable... I have looked at the doc but i did
not found anything.

What I want is simply do the follow:

1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table/rowset
3. Save (clicking on a button): commit the rowset to the database

Otherwise:
1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table
3. Save(clicking on a button): remapping of the table in the roset
4. and then commit the rowset to the database

Any suggestion on how to do this in the simplest way is greatly
appreciated...

Thanks in advance,
Andrea
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrea Sansottera wrote:
Hi fellows,

I was wondering if in the Java API there's a way to easily map a
disconnected RowSet to a JTable... I have looked at the doc but i did
not found anything.

What I want is simply do the follow:

1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table/rowset
3. Save (clicking on a button): commit the rowset to the database

Otherwise:
1. Load: Database -> disconected Rowset -> automapping in a JTable
2. Editing of the data in the table
3. Save(clicking on a button): remapping of the table in the roset
4. and then commit the rowset to the database

Any suggestion on how to do this in the simplest way is greatly
appreciated...

Thanks in advance,
Andrea

I wouldn't waste your time with the disconnected Rowset... You can
operate on the live one just as well... The caveat is that the table
you show can't be created as a result of an SQL join.

That being said, just implement a TableModel that delegates to the
Rowset (or ResultSet). The key is figuring out how many rows there are.
You can either move the SQL cursor to the end and find out the current
row or run another statement like "SELECT Count(*) From...)

Once you've got the row number for the TableModel, you don't have to
read all of the rows to satisfy the TableModel requirement. As for the
data access, just move the SQL Cursor to the appropriate column/row when
requested by the JTable.

Access is quite fast, and you don't even have to read the entire ResultSet.
As for updating, there's the ResultSet API that allows you to edit the
data in place.

-Bryan
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.