This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSF and the fly likes Automatic database update and mail from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Automatic database update and mail from java" Watch "Automatic database update and mail from java" New topic

Automatic database update and mail from java

Dhamayanthi Karuppanan
Ranch Hand

Joined: Oct 20, 2009
Posts: 31
I'm developing a small web application for leave management system, where employees can apply and supervisors can approve / reject them and the same will be intimated by a mail. I have a requirement where all the leave requests that are older than a day should be approved automatically. Is there any way to do this from java side?

I use Java, JSF and Database is MySQL. Please help me. Thanks for your help.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

You can use a "cron task" to automatically rubberstamp requests that are older than 24 hours. On Unix/Linux systems, you can literally use the "cron" utility to run the mysql command-line processor and have it execute a SQL command. Windows also has a scheduler, although theirs is a little harder for most people to figure out.

Or, you can run an internal webapp process to do the same time, executing a JDBC request from Java Code. For something simple like this, you can just spawn a thread from an application contextListener to use the java Timer class. For more complex scheduling, a powerful alternative is the Quartz Scheduler.

An IDE is no substitute for an Intelligent Developer.
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

What app server are you using? the EJB timer service is something to consider if
it's supported in your environment. You mention the front end, the back end, but
omit any mention of anything in between.

I agree. Here's the link:
subject: Automatic database update and mail from java
It's not a secret anymore!