定时问题 ORACLE 有作业来实现的不用写到项目里,如果非要用java 还不用框架来弄的话可以考虑下
在xml中配置监听
<listener-class>com.timer.MyListener</listener-class>
<困知/listener>汪稿消
<listener>
<listener-class>com.IMS.ImsListener</listener-class>
</listener>
import java.util.Timer;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class MyListener implements ServletContextListener {
private Timer timer = null;
public void contextInitialized(ServletContextEvent event) {
timer = new Timer(true);
//调用执行类设置任务计划,启动和间隔时间
timer.schedule(new MyTask(), 10000, 30000);
}
public void contextDestroyed(ServletContextEvent event) {
timer.cancel();
}
}
//执行类
import java.util.TimerTask;
public class MyTask extends TimerTask {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("1113");
}
}
package com.timer;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.TimerTask;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.olive.sebb.wlbqz.domain.SebbWlbqz;
import com.olive.sebb.wlbqz.service.WlbqzService;
import com.olive.sebb.wlbqz.service.WlbqzServiceImpl;
import com.opensymphony.webwork.ServletActionContext;
//敬汪执行定时任务
public class MyTask extends TimerTask {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("1113");
}
}