Quartz scheduler Failed to obtain DB connection from data source
I'm trying to setup quartz scheduler with mysql database and I'm getting the below exception. Can someone help me on this, Please.
I have included the below jars:
c3p0-0.9.1.1.jar
jta-1.1.jar
mysql-connector-java-5.1.27.jar
quartz-2.2.1.jar
quartz-jobs-2.2.1.jar
slf4j-api-1.7.10.jar
slf4j-simple-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
This is the 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
quartz-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>
Main class
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();
}
}
}
Job class
import org.quartz.Job;
import org.quartz.JobExecutionContext;
public class HelloJob implements Job {
public void execute(JobExecutionContext context){
System.out.println("Hello World !!!");
}
}
I found the reason for the issue.
scheduler.shutdown();
This statement shutdown the quartz server before the job trigger and the connection is no more available.
链接地址: http://www.djcxy.com/p/23638.html上一篇: 如何在PHP中定义一个空对象