1

Quartz をダウンロードして、サンプルを実行しようとしています。

whichを使用したサンプルは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
4

3 に答える 3

2

java.sql.SQLException: フィールド 'PRIORITY' にデフォルト値がありません

上記の例外を見れば、どこに問題があるかがわかると思います。

于 2009-09-25T02:13:47.240 に答える
0

Quartz 1.6.5 で試してみましたが、結果は見つかりませんでしたが、Quartz 1.5 でそれを実行しました。JDBC ジョブストアの 1.6.5 にバグがある可能性があります。ムハンマド

于 2009-08-18T10:28:07.450 に答える
0

私は同様の問題を抱えていましたが、それは私の悪いことでした..バージョン2.1.1を使用していて、2.2.1のドキュメントからテーブルを作成したため、Mavenでバージョンを更新しましたが、現在は正常に動作しています.

于 2014-03-21T01:12:01.983 に答える