Quartz JDBCJobstore不起作用

时间:2009-08-08 09:37:38

标签: quartz-scheduler

我已下载Quartz,我正在尝试运行示例。

我有一个使用JDBCJobStore但不起作用的示例,但此示例适用于RAMJobStore

当我选择JDBCJobStore并且异常被提升时。

我正在使用quartz-1.6.5。

代码:

package test;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;



public class ReportRunner {
    public static void main(String[] args) {
        try {

            SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
            Scheduler sched = schedFact.getScheduler();
            sched.start();

            JobDetail jobDetail = null;
            SimpleTrigger trigger2 = null;

            jobDetail = new JobDetail("Income Report", "Report Generation",
                    QuartzReport.class);
            jobDetail.getJobDataMap().put("type", "FULL");
            jobDetail.setDurability(true);

            trigger2 = new SimpleTrigger("Income Report", "Report Generation");

            trigger2.setStartTime(new java.util.Date(
                    System.currentTimeMillis() + 4000));
            trigger2.setRepeatInterval(5000);
            trigger2.setRepeatCount(100);
            sched.scheduleJob(jobDetail, trigger2);



        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

package test;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

public class QuartzReport implements Job {

    public void execute(JobExecutionContext cntxt) throws JobExecutionException {
        System.out.println("Generating report - "
                + cntxt.getJobDetail().getJobDataMap().get("type"));

    }
}

配置文件:

org.quartz.scheduler.instanceName = Sched1
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 3
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = myDS
org.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL = jdbc:mysql://192.168.0.4:3306/conference
org.quartz.dataSource.myDS.user = root
org.quartz.dataSource.myDS.password =root
org.quartz.dataSource.myDS.maxConnections 5 

这个激活在运行时显示,它已被记录


org.quartz.JobPersistenceException: Couldn't acquire next trigger: Field 'PRIORITY' doesn't have a default value [See nested exception: java.sql.SQLException: Field 'PRIORITY' doesn't have a default value]
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:1778)
    at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1218)
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:233)
* Nested Exception (Underlying Cause) ---------------
java.sql.SQLException: Field 'PRIORITY' doesn't have a default value
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.insertFiredTrigger(StdJDBCDelegate.java:3360)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:1771)
    at org.quartz.impl.jdbcjobstore.JobStoreTX.acquireNextTrigger(JobStoreTX.java:1218)
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:233)
547  [QuartzScheduler_MyClusteredScheduler-NON_CLUSTERED_MisfireHandler] DEBUG org.quartz.impl.jdbcjobstore.SimpleSemaphore  - Lock 'TRIGGER_ACCESS' retuned by: QuartzScheduler_MyClusteredScheduler-NON_CLUSTERED_MisfireHandler

3 个答案:

答案 0 :(得分:2)

  

java.sql.SQLException:Field   'PRIORITY'没有默认值   值

我想你可以通过查看上面的例外来判断问题所在。

答案 1 :(得分:0)

我尝试使用Quartz 1.6.5并且我没有找到任何结果,但是它与Quartz 1.5一起使用。我想在JDBC jobstore中可能存在1.6.5中的一些错误。 穆罕默德

答案 2 :(得分:0)

我有一个类似的问题,这是我的坏...因为我使用的是2.1.1版,我从2.2.1的文档创建了表格,我在Maven中更新了版本,现在工作正常。