java - Quartz scheduler - each time new jdbc connection -
i have problem quartz scheduler , configuration database. every time scheduler check if new job exist created new jdbc connections. how avoid create new connection ?
2015-06-19 10:42:05,522 debug drivermanagerdatasource:142 - creating new jdbc drivermanager connection [jdbc:mysql://localhost:3306/db?characterencoding=utf-8] 2015-06-19 10:42:05,544 debug localdatasourcejobstore:3182 - found 0 triggers missed scheduled fire-time. 2015-06-19 10:42:05,545 debug datasourceutils:327 - returning jdbc connection datasource 2015-06-19 10:42:07,522 debug localdatasourcejobstore:3933 - misfirehandler: scanning misfires... 2015-06-19 10:42:07,522 debug drivermanagerdatasource:142 - creating new jdbc drivermanager connection [jdbc:mysql://localhost:3306/db?characterencoding=utf-8] 2015-06-19 10:42:07,539 debug localdatasourcejobstore:3182 - found 0 triggers missed scheduled fire-time. 2015-06-19 10:42:07,539 debug datasourceutils:327 - returning jdbc connection datasource
and configuration
<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>
and datasource, same hibernate , quartz scheduler
<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>
as far see use org.springframework.jdbc.datasource.drivermanagerdatasource
class data source. according javadoc creates jdbc connection every time call getconnection
. i'm sure quartz call method internally.
to solve problem should use pooled datasource. example, c3p0 (look @ com.mchange.v2.c3p0.combopooleddatasource
)
Comments
Post a Comment