Quartz JDBCJobStore problems with MySQL

空扰寡人 提交于 2020-01-14 04:24:07

问题


I'm trying to use Job persistence via job store in my spring mvc project, but something seems wrong in my database structure.

My database is MySQL (v 5.6.15) and I created tables using scripts in Quartz jar (v 1.8.6).

Executing some test I found that jobs and triggers are persisted in DB and (I hope) correctly loaded, but they aren't executed. Trigger status is always on "WAITING".

I tried creating tables structure on a SqlServer instance (always using scripts provided) and, now it works!!! So, what's wrong with MySql?

The only difference I notice is that table names in MySQL are lowercase, instead of all uppercase as in SqlServer, could it be a problem?

My configuration is the following:

Scheduler configuration via spring

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="quartzProperties">
        <map>
            <entry key="org.quartz.scheduler.instanceName" value="gep_scheduler" />
            <!-- ThreadPool -->
            <entry key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool" />
            <entry key="org.quartz.threadPool.threadCount" value="3" />
            <entry
                key="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread"
                value="true" />
            <!-- JobStore -->
            <entry key="org.quartz.jobStore.class" value="org.quartz.impl.jdbcjobstore.JobStoreTX" />
            <entry key="org.quartz.jobStore.driverDelegateClass" value="org.quartz.impl.jdbcjobstore.StdJDBCDelegate" />
            <entry key="org.quartz.jobStore.tablePrefix" value="qrtz_" />
            <entry key="org.quartz.jobStore.dataSource" value="qzDS" />
            <entry key="org.quartz.jobStore.isClustered" value="false" />
            <entry key="org.quartz.jobStore.misfireThreshold" value="60000" />
            <!-- DataSource -->
            <entry key="org.quartz.dataSource.qzDS.driver" value="${db.driver}" />
            <entry key="org.quartz.dataSource.qzDS.URL" value="${db.url}" />
            <entry key="org.quartz.dataSource.qzDS.user" value="${db.user}" />
            <entry key="org.quartz.dataSource.qzDS.password" value="${db.password}" />
            <entry key="org.quartz.dataSource.qzDS.maxConnections" value="${db.maxActivePools}" />
            </map>
    </property>
</bean>

NOTE no exception is thrown.


回答1:


I finally caught an exception from the scheduler:

org.quartz.JobPersistenceException: Couldn't acquire next trigger: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=5' at line 1

The problem was in MySQL driver. I was using v5.1.6 that seems not compatible with MySQL 5.6.x versions.

I solved importing last version of mysql-connector (at the moment v5.1.31).



来源:https://stackoverflow.com/questions/24259524/quartz-jdbcjobstore-problems-with-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!