基于quartz的定时任务_第1页
基于quartz的定时任务_第2页
基于quartz的定时任务_第3页
基于quartz的定时任务_第4页
免费预览已结束,剩余1页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本文格式为Word版,下载可任意编辑——基于quartz的定时任务功能概述:

1首页显示自己添加的定时任务

1.1点击新增可以添加定时任务

1.2任务状态分为:运行中、暂停、已失效,运行中的任务可以删除、编

辑、暂停,已失效的任务只可以删除、编辑(重新编辑后任务可以再次运行)

2任性新增界面

2.12.22.32.4

编写任务标题

编写提醒内容(提醒内容无字数限制)提醒时间可以选择详细、每日、每周、每月、cron(类似Linux的cron)向谁提醒可以选择多人

功能实现:

1定时任务持久化

假使定时任务不进行持久化配置用户设置的定时任务会保存在内存中,应用重启后定时任务就不存在了。1.1配置文件

各配置参数请自己百度

org.quartz.scheduler.instanceName=DefaultQuartzSchedulerorg.quartz.scheduler.rmi.export=falsexy=false

org.quartz.scheduler.wrapJobExecutionInUserTransaction=falseorg.quartz.threadPool.class:org.quartz.simpl.SimpleThreadPoolorg.quartz.threadPool.threadCount:10org.quartz.threadPool.threadPriority:5

org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread:false

#org.quartz.jobStore.misfireThreshold=100000

org.quartz.jobStore.class:org.quartz.impl.jdbcjobstore.JobStoreTXorg.quartz.jobStore.driverDelegateClass:org.quartz.impl.jdbcjobstore.StdJDBCDelegate

org.quartz.jobStore.useProperties:tureorg.quartz.jobStore.dataSource:myDSorg.quartz.jobStore.tablePrefix:QRTZ_org.quartz.jobStore.isClustered:false#上线时需要修改数据库配置

org.quartz.dataSource.myDS.connectionProvider.class:tool.remind.MyPoolingconnectionProvider

#org.quartz.dataSource.myDS.driver:com.mysql.jdbc.Driver#org.quartz.dataSource.myDS.URL:

jdbc:mysql://localhost:3306/zcglpz1?characterEncoding=utf-8zeroDateTimeBehavior=convertToNull

org.quartz.dataSource.myDS.driver=net.sf.log4jdbc.DriverSpyorg.quartz.dataSource.myDS.URL=jdbc:log4jdbc:mysql://localhost:3306/zcglpz1?characterEncoding=utf-8zeroDateTimeBehavior=convertToNull

org.quartz.dataSource.myDS.user:rootorg.quartz.dataSource.myDS.password:123654org.quartz.dataSource.myDS.maxConnections:5

1.2编写MyPoolingconnectionProvider.java类

packagetool.remind;importjava.sql.Connection;importjava.sql.SQLException;

importmons.dbcp.BasicDataSource;importorg.quartz.SchedulerException;importorg.quartz.utils.ConnectionProvider;

publicclassMyPoolingconnectionProviderimplementsConnectionProvider{privateBasicDataSourcedatasource;privateStringdbDriver;privateStringURL;privateStringdbUser;privateStringdbPassword;privateintmaxConnections;

privateintmaxStatementsPerConnection;privateStringdbValidationQuery;privatebooleanvalidateOnCheckout;privateintidleValidationSeconds;privateintmaxIdleSeconds;

publicMyPoolingconnectionProvider(){

}

privatevoidinitialize(StringdbDriver,StringURL,StringdbUser,StringdbPassword,intmaxConnections,intmaxStatementsPerConnection,String

dbValidationQuery,booleanvalidateOnCheckout,intidleValidationSeconds,intmaxIdleSeconds)throwsSQLException,SchedulerException{if(URL==null){

thrownewSQLException(\}

if(dbDriver==null){thrownewSQLException(\\}

if(maxConnections<0){thrownewSQLException(\\}

datasource=newBasicDataS

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论