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

发布于 2024-07-17 23:54:32 字数 45 浏览 3 评论 0原文

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

谢谢。

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

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长途伴 2024-07-24 23:54:32

您的 JTable 数据模型 必须以某种方式确定您的数据库是否已更改。

没有标准方法可以将这些信息直接从 SQL 数据库提供给表模型。 最有可能的是,您必须轮询数据库并自己发现此信息(在轮询线程中?)

根据填充表所需的查询的复杂性以及表中数据的数量,您可以轮询以获取返回完整的数据集并在必要时重建表,或者轮询最新更新的行,然后在发生更改时发出对完整数据集的查询。

根据您使用的是特定框架还是 SQL 数据库产品,这个问题可能有更多特定于产品的答案。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文