DB2的存储过程,如何设置时间调度,定时自动执行

我在db2中,写了一个存储过程,需要定时执行,例如每天凌晨:02:00:00,请问该如何实现了

create event TESTEVENT
on schedule every 1 DAY STARTS '2016-08-22 02:00:00'
on completion preserve enable
do BEGIN
call PROCEDURE();
END;

参考自:
mysql 定时任务 event http://www.data.5helpyou.com/article201.html

package Test1;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
/**

  • 相比于Timer的单线程,它是通过线程池的方式来执行任务的 可以很灵活的去设定第一次执行任务delay时间 提供了良好的约定,以便设定执行的时间间隔
  • @author Administrator
    *
    */
    public class TimeTask3 {
    public static void main(String[] args) {
    executeEightAtNightPerDay();

    }
    /**

    • 每天凌晨2点执行一次
    • 每天定时安排任务进行执行 /
      public static void executeEightAtNightPerDay() {
      ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
      long oneDay = 24 * 60 * 60 * 1000;
      long initDelay = getTimeMillis("2:00:00") - System.currentTimeMillis();
      initDelay = initDelay > 0 ? initDelay : oneDay + initDelay;
      Runnable runnable = new Runnable() { public void run() { // task to run goes here //此处填写调用你的存储过程 System.out.println("Hello !!"); } }; executor.scheduleAtFixedRate(
      runnable,
      initDelay,
      oneDay,
      TimeUnit.MILLISECONDS);
      } /
      *
    • 获取指定时间对应的毫秒数
    • @param time "HH:mm:ss"
    • @return */
      private static long getTimeMillis(String time) {
      DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
      DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd");
      Date curDate; try { curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time); return curDate.getTime(); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); }
      return 0;
      }
      }