Results 1 to 4 of 4
  1. #1
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default Scheduling a task

    I have a class written in Java that connects to a MySQL database and updates few tables. It works perfectly fine.

    I have to run it after every 4 hours. I want to automate it using some scheduling. How can this be done. Please help me out.

    Thanks a lot.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default

    You can create a java.util.TimerTask implementation that do your database update. Then run this task using java.util.Timer class every 4 hours as you required. I have a small example on how to use these classes here: How do I create a scheduled task using timer? You can just modified it to fit your requirement.

  3. #3
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default

    Thanks mate.
    But I don't wan to run the code my self. I want some background process to keep monitoring the time and after 4 hours, it should trigger the class.

    Something like Window Scheduling.

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default

    Well, there must be an application to execute the job right. This application can be your own java class or maybe you can also execute it from the windows scheduler. If it can run any command line you can ask the windows scheduler to execute java command to run your class.

    There is also some great library for scheduling such as Quartz that you can also use for creating the scheduler.

Similar Threads

  1. PLZ...PLZ!!!HELP ME TO WRITE THE TASK 2's CODES
    By hhoa87 in forum Advanced Java
    Replies: 3
    Last Post: 03-23-2008, 12:50 AM
  2. java : how to hide application icon from a task bar
    By yogeshagashe in forum Advanced Java
    Replies: 0
    Last Post: 03-12-2008, 02:05 PM
  3. Scheduling tasks using Threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 11:24 AM
  4. String Manipulation Task
    By hiranya in forum New To Java
    Replies: 1
    Last Post: 11-19-2007, 12:07 PM
  5. Task Blocks 0.5
    By johnt in forum Java Software
    Replies: 0
    Last Post: 08-08-2007, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •