简体   繁体   English

如何在更新数据库时自动更新JTable数据?

[英]How can I update my JTable data automatically when the database is updated?

How can I update my JTable data automatically when my database is updated? 如何在更新数据库时自动更新JTable数据?

Thanks. 谢谢。

Your JTable data model will somehow have to determine whether your database has changed. 您的JTable 数据模型将以某种方式确定您的数据库是否已更改。

There's no standard way of feeding this info direct from a SQL database to a table model. 没有标准的方法可以直接从SQL数据库向表模型提供此信息。 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. 根据您使用的是特定框架还是SQL数据库产品, 可能会有更多针对此问题的产品特定答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM