Quartz scheduler无法从数据源获取数据库连接
我正在尝试使用mysql数据库来设置石英调度程序,并且我得到了下面的异常。 有人可以帮我解决这个问题吗?
我已经包括了下面的罐子:
c3p0-0.9.1.1.jar
JTA-1.1.jar
MySQL的连接器的Java-5.1.27.jar
石英2.2.1.jar
石英工作-2.2.1.jar
SLF4J-API 1.7.10.jar
SLF4J-简单1.7.25.jar
[LMWJobScheduler_QuartzSchedulerThread] ERROR org.quartz.core.ErrorLogger - An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'myDS': java.sql.SQLException: com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [lastAcquisitionFailureDefaultUser] ] has been closed() -- you can no longer use it. [See nested exception: java.sql.SQLException: com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [lastAcquisitionFailureDefaultUser] ] has been closed() -- you can no longer use it.]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:778)
at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:71)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3784)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2756)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:272)
Caused by: java.sql.SQLException: com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [lastAcquisitionFailureDefaultUser] ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.assertCpds(AbstractPoolBackedDataSource.java:447)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getPoolManager(AbstractPoolBackedDataSource.java:459)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.quartz.utils.PoolingConnectionProvider.getConnection(PoolingConnectionProvider.java:247)
at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:108)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:775)
... 4 more
这是quartz.properties
org.quartz.scheduler.instanceName: JobScheduler
org.quartz.scheduler.instanceId: AUTO
org.quartz.scheduler.skipUpdateCheck: true
org.quartz.plugin.jobInitializer.class =org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-config.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 20
org.quartz.threadPool.threadPriority: 5
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=true
org.quartz.dataSource.myDS.driver: com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL: jdbc:mysql://localhost:3306/quartz
org.quartz.dataSource.myDS.user: root
org.quartz.dataSource.myDS.password: password
org.quartz.dataSource.myDS.maxConnections: 5
石英-config.xml中
http://www.quartz-scheduler.org/xml/job_scheduling_data_2_0.xsd“version =”2.0“>
<schedule>
<job>
<name>Hello</name>
<group>HelloGroup</group>
<description>The job description</description>
<job-class>HelloJob</job-class>
</job>
<trigger>
<cron>
<name>hello-trigger</name>
<group>Hello_Group</group>
<job-name>Hello</job-name>
<job-group>HelloGroup</job-group>
<cron-expression>0/30 0/1 * 1/1 * ?</cron-expression>
</cron>
</trigger>
</schedule>
主要类
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
public class QuartzTest {
public static void main(String[] args) {
try {
// Grab the Scheduler instance from the Factory
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
// and start it off
scheduler.start();
scheduler.shutdown();
} catch (SchedulerException se) {
se.printStackTrace();
}
}
}
工作班
import org.quartz.Job;
import org.quartz.JobExecutionContext;
public class HelloJob implements Job {
public void execute(JobExecutionContext context){
System.out.println("Hello World !!!");
}
}
我找到了问题的原因。
scheduler.shutdown();
该语句在作业触发器之前关闭石英服务器,并且连接不再可用。
链接地址: http://www.djcxy.com/p/23637.html上一篇: Quartz scheduler Failed to obtain DB connection from data source
下一篇: java