views:

1038

answers:

1

How can I update my JTable data automatically when my database is updated?

Thanks.

+1  A: 

Your JTable data model will somehow have to determine whether your database has changed.

There's no standard way of feeding this info direct from a SQL database to a table model. Most likely you will have to poll the database and discover this info for yourself (in a polling thread?)

Depending on the complexity of the query required to populate the table, and the quantity of the data in the table, you can poll to get the complete data set back and rebuild the table if necessary, or poll for the latest updated row, and then issue a query for the complete dataset if this has changed.

Depending on whether you're using particular frameworks or SQL database products, there may be more product-specific answers to this question.

Brian Agnew