aspose file tools*
The moose likes Servlets and the fly likes Scheduling a class to run automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Scheduling a class to run automatically" Watch "Scheduling a class to run automatically" New topic
Author

Scheduling a class to run automatically

Xon Bhuyan
Greenhorn

Joined: Sep 24, 2003
Posts: 11
I am using a core java class to perform som database transections. I want that the program runs automatically at a particular time everyday. Yes, I am taking about a web-server environment (Tomcat). How it can be done?


Xon Bhuyan
deepak kukreja
Ranch Hand

Joined: Aug 13, 2001
Posts: 54
Well thats a simple task. Just put ur class in a loop like
while(true), and break out of it whenever required. use threading model
for implementing this class. U can read datadase records after a certain
amount of time and then accordingly operate ......


Deepak<br />SCJP
Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
I did something similar recently with java.util.Timer and java.util.TimerTask - really easy to do and works great! I made a JSP that is used to configure the interval.
brian


My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
I agree with Brian, I've done the same thing also and it works like a charm.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

"XoN"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
It can be done by making a cron job(unix) or adding in scheduler(windows)


Sanjeev Kaushik
Xon Bhuyan
Greenhorn

Joined: Sep 24, 2003
Posts: 11
Oooh, I was not aware of the naming policy. Anyway, xon is my name and I have changed it to Xon Bhuyan now. Hope this is fine.
Originally posted by Mark Spritzler:
"XoN"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark

[ October 01, 2003: Message edited by: Xon Bhuyan ]
Xon Bhuyan
Greenhorn

Joined: Sep 24, 2003
Posts: 11
Thanks all. I tried it by both Threads and Windows Task Scheduler. It worked..
[ October 01, 2003: Message edited by: Xon Bhuyan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scheduling a class to run automatically