Java DB 检查日期/时间字段(事件处理)?
我如何在java中提出一种机制,可以监视Java DB表内的日期/时间字段,并且一旦一个或多个记录的日期/时间字段与系统时间匹配,我就可以获取它们进一步处理??!示例代码将不胜感激!
How can I come up with a mechanism in java where I could monitor the date/time fields inside a Java DB table and as soon as the the date/time fields for one or many of the records match the system time I could grab them for further processing??! Sample code would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将数据库中的日期/时间字段设置为时间戳。然后从数据库中获取该字段的值。并将当前时间以毫秒为单位换算然后进行比较。
Make date/time field in DB as Timestamp. Then get the value of this field from database. And convert the current time in millisecond and then compare.
您当然可以使用触发器 - 这些是当特定事件发生时由 DBMS 自动执行的数据库过程,其中一个此类事件可能是日期/时间字段值的更改。
这些过程是在数据库本身中实现的,而不是在您的java代码中实现的。
这里是关于数据库触发器的维基百科文章。
You can surely use triggers - those are DB procedures that get executed by DBMS automatically, when a particular event arises, and one such event could be the change of the value of yours date/time fields.
Those procedires are implemented into DB itself, not into your java code.
Here is the wikipedia article on DB triggers.