Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scheduling Pls Help

 
allen turner
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
I want to update a database on a daily basis using java at some predefined times of the day. is this possible? What i am looking at is some kind of a cron job like facility like in linux.
Thanks
Bye
 
Fei Ng
Ranch Hand
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just a idea,
have a cron runs a shell script which runs java program.
or just have a perl or shell script do it directly.
 
Shubhrajit Chatterjee
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For any UNIX system you can write a cron job as specifed in the previous reply. If u use windows NT then create a new scheduled task to invoke a batch file which invokes Java.
------------------
Shubhrajit
 
allen turner
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
But i want to do it from java so that i need not depend on the facility given by the platform like NT or linux. if i can do it in java no matter waht the platform it will work!!. So i specifically need it in java.
Bye
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course you can do this, and event handling is the way to do it. Think about it this way: you have a Cron object (hey why not, the word's not copyrighted) that will tell other objects when a time they have expressed interest in comes around. When it happens, the Cron class creates a TimedEvent object, and sends it as a parameter to a Listener that knows what job needs to be performed.
For a task like this you don't really need OS services. Your VM does, of course, but that's already built into it.
Is that enough to go on?
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
allen turner
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
I think i can work on that idea. Is there any useful jars that can do all this kind of things?
Thanks
 
Chidda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allen,
JDK1.3 exposes couple of classes java.util.Timer and java.util.TimerTask that actually does the job of Scheduling (It is rudimentary thread based implementation). It is pretty simple to build a robust client around Timer and TimerTask.
Hope this helps.
Chidda
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic