我有Quartz Scheduler和數據庫配置的問題。每當調度程序檢查新作業是否存在時,都會創建新的JDBC連接。如何避免創建新的連接?石英調度程序 - 每次新的jdbc連接
2015-06-19 10:42:05,522 DEBUG DriverManagerDataSource:142 - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/db?characterEncoding=UTF-8]
2015-06-19 10:42:05,544 DEBUG LocalDataSourceJobStore:3182 - Found 0 triggers that missed their scheduled fire-time.
2015-06-19 10:42:05,545 DEBUG DataSourceUtils:327 - Returning JDBC Connection to DataSource
2015-06-19 10:42:07,522 DEBUG LocalDataSourceJobStore:3933 - MisfireHandler: scanning for misfires...
2015-06-19 10:42:07,522 DEBUG DriverManagerDataSource:142 - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/db?characterEncoding=UTF-8]
2015-06-19 10:42:07,539 DEBUG LocalDataSourceJobStore:3182 - Found 0 triggers that missed their scheduled fire-time.
2015-06-19 10:42:07,539 DEBUG DataSourceUtils:327 - Returning JDBC Connection to DataSource
而且配置
<bean id="scheduler" name="scheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
scope="singleton">
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.instanceName">USER_JOBS</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
</prop>
<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
<prop key="org.quartz.jobStore.isClustered">false</prop>
<prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
<prop key="org.quartz.jobStore.misfireThreshold">2000</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
和數據源,同爲休眠和石英調度
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>
您應該使用池數據源http://stackoverflow.com/questions/9745165/what-pooled-data-source-should-i-use-for-spring-3- 1-0-hibernate-4-0-1-final-an – Jens
@Jens我認爲這實際上是對這個問題的回答。在我的腦中增加了一些東西。謝謝.. –