日期:2014-05-16  浏览次数:20655 次

定时器(quartz+spring)读取数据库配置

??? 今天把项目中的一部分移出来,主要是实现定时器任务,定时任务是从数据库配置的的,所以采用spring读取数据库配置文件来实现定时器。

需要的JAR包 见上传文件

数据建立? 见上传文件


数据库映射类:


package com.quartz;



public class DbsynConfigQuartz {
???
??? // Fields

??? private String triggername;
??? private String cronexpression;
??? private String jobdetailname;
??? private String targetobject;
??? private String methodname;
??? private String concurrent;
??? private String state;
??? private String readme;
??? private String isspringbean;

??? // Constructors

??? /** default constructor */
??? public DbsynConfigQuartz() {
??? }

??? /** minimal constructor */
??? public DbsynConfigQuartz(String triggername, String jobdetailname,
??? ??? ??? String targetobject, String concurrent, String state,String isspringbean) {
??? ??? this.triggername = triggername;
??? ??? this.jobdetailname = jobdetailname;
??? ??? this.targetobject = targetobject;
??? ??? this.concurrent = concurrent;
??? ??? this.state = state;
??? ??? this.isspringbean=isspringbean;
??? }

??? /** full constructor */
??? public DbsynConfigQuartz(String triggername, String cronexpression,
??? ??? ??? String jobdetailname, String targetobject, String methodname,
??? ??? ??? String concurrent, String state, String readme,String isspringbean) {
??? ??? this.triggername = triggername;
??? ??? this.cronexpression = cronexpression;
??? ??? this.jobdetailname = jobdetailname;
??? ??? this.targetobject = targetobject;
??? ??? this.methodname = methodname;
??? ??? this.concurrent = concurrent;
??? ??? this.state = state;
??? ??? this.readme = readme;
??? ??? this.isspringbean=isspringbean;
??? }

??? // Property accessors

??? public String getTriggername() {
??? ??? return this.triggername;
??? }

??? public void setTriggername(String triggername) {
??? ??? this.triggername = triggername;
??? }

??? public String getCronexpression() {
??? ??? return this.cronexpression;
??? }

??? public void setCronexpression(String cronexpression) {
??? ??? this.cronexpression = cronexpression;
??? }

??? public String getJobdetailname() {
??? ??? return this.jobdetailname;
??? }

??? public void setJobdetailname(String jobdetailname) {
??? ??? this.jobdetailname = jobdetailname;
??? }

??? public String getTargetobject() {
??? ??? return this.targetobject;
??? }

??? public void setTargetobject(String targetobject) {
??? ??? this.targetobject = targetobject;
??? }

??? public String getMethodname() {
??? ??? return this.methodname;
??? }

??? public void setMethodname(String methodname) {
??? ??? this.methodname = methodname;
??? }

??? public String getConcurrent() {
??? ??? return this.concurrent;
??? }

??? public void setConcurrent(String concurrent) {
??? ??? this.concurrent = concurrent;
??? }

??? public String getState() {
??? ??? return this.state;
??? }

??? public void setState(String state) {
??? ??? this.state = state;
??? }

??? public String getReadme() {
??? ??? return this.readme;
??? }

??? public void setReadme(String readme) {
??? ??? this.readme = readme;
??? }

??? public String getIsspringbean() {
??? ??? return isspringbean;
??? }

??? public void setIsspringbean(String isspringbe