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!
Asked
Active
Viewed 183 times
2 Answers
0
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.
java.util.Date utilDate=new java.util.Date();
java.sql.Timestamp timest=new Timestamp(utilDate.getTime());
timest.compareTo(timest2);

KV Prajapati
- 93,659
- 19
- 148
- 186

vikas27
- 563
- 5
- 14
- 36
0
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.

karla
- 4,506
- 5
- 34
- 39