Reputation: 8556
I' m developing application in Java which is connected to database (Oracle or SQLite). In database I store contracts. The contract has field access_date
. And i want to check this field once every day and if one day access_date
will be equal to the current date then mark the contract as not valid. How can I implement this? In PHP as far as I know there are cron jobs for such tasks but what about java or java ee? How can I do this?Thanks in advance!
Upvotes: 1
Views: 2852
Reputation: 52386
Instead of saving an attribute for the contract not being valid, and having to check it against sysdate every day, I would use a predicate such as "access_date < trunc(sysdate)" to find expired contracts, and an expression such as:
case when access_date < trunc(sysdate) then 'N' else 'Y' end
... to display whether a contract is active or not.
Upvotes: 0
Reputation: 3214
You can do this in two ways:
Upvotes: 2
Reputation: 68715
Use either TimerTask or ScheduledTask. Here is a good tutorial for that:
http://www.ibm.com/developerworks/java/library/j-schedule/index.html
Upvotes: 0