File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scheduling a class to run automatically

 
Xon Bhuyan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
deepak kukreja
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ......
 
Brian Pipa
Ranch Hand
Posts: 299
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Phil Chuang
Ranch Hand
Posts: 251
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Brian, I've done the same thing also and it works like a charm.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can be done by making a cron job(unix) or adding in scheduler(windows)
 
Xon Bhuyan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all. I tried it by both Threads and Windows Task Scheduler. It worked..
[ October 01, 2003: Message edited by: Xon Bhuyan ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic