Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hikari cp, upgrade c3p0 library, break static dependencies #126

Merged

Conversation

jhouserizer
Copy link
Contributor

@jhouserizer jhouserizer commented Apr 15, 2017

Replaces #20
Add a connection provider for HikariCP
Update to latest C3p0
Break static dependecies on C3p0 so that it isn't required on the class path even if you're not using it

Also addresses minor concerns in #19

@jhouserizer jhouserizer merged commit b5ac816 into quartz-scheduler:master Apr 15, 2017
@jhouserizer jhouserizer added this to the 2.3.0 milestone Apr 15, 2017
@jhouserizer jhouserizer deleted the add_hikari_connection_pool branch April 15, 2017 17:30
@stefanwendelmann
Copy link

how can i activate the hikaricp pool in my quartz.properties?

@x418
Copy link

x418 commented Aug 26, 2017

@stefanwendelmann If you are still looking for an answer, we recently switched quartz to use Hikaricp and do it as below (we use Spring for IoC)

//Create the datasource

  @Bean(destroyMethod = "close")
  @DependsOn("flyway")
  public HikariDataSource hikariDataSource() {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(env.getProperty("database.url", "jdbc_url....."));
    config.setDriverClassName("driver class name...");
    config.setUsername(env.getProperty("database.username", "username..."));
    config.setPassword(env.getProperty("database.password", "password..."));
    config.setMinimumIdle(env.getProperty("database.connectionPool.size.min", Integer.class, 5));
    config.setMaximumPoolSize(env.getProperty("database.connectionPool.size.max", Integer.class, 10));
    config.setMetricRegistry(metricRegistry);
    config.setAutoCommit(false);
    return new HikariDataSource(config);
  }

And then inject the datasource as below

 @Bean
  @Profile(value = {"prod"})
  public SchedulerFactoryBean schedulerFactoryBean(DataSource hikariDataSource,
                                                   PlatformTransactionManager transactionManager) {
    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    setSchedulerParameters(hikariDataSource, transactionManager, schedulerFactoryBean);

    return schedulerFactoryBean;
  }

@zemian
Copy link
Contributor

zemian commented Aug 26, 2017 via email

@xcorpio
Copy link

xcorpio commented Jan 22, 2018

hi, @zemian , after adding

    org.quartz.dataSource.CommonDS.provider = hikaricp
    org.quartz.dataSource.CommonDS.connectionProvider.class = org.quartz.utils.HikariCpPoolingConnectionProvider

will cause a exception:

Caused by: org.quartz.SchedulerException: ConnectionProvider class 'org.quartz.utils.HikariCpPoolingConnectionProvider' could not be instantiated. [See nested exception: java.lang.InstantiationException: org.quartz.utils.HikariCpPoolingConnectionProvider]
	at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:936)
	at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1559)
	...
	... 14 more
Caused by: java.lang.InstantiationException: org.quartz.utils.HikariCpPoolingConnectionProvider
	at java.lang.Class.newInstance(Class.java:427)
	at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:934)
	... 17 more
Caused by: java.lang.NoSuchMethodException: org.quartz.utils.HikariCpPoolingConnectionProvider.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.newInstance(Class.java:412)
	... 18 more

@xcorpio
Copy link

xcorpio commented Jan 22, 2018

if only add org.quartz.dataSource.CommonDS.provider = hikaricp this one line, it seems to work

@enwired
Copy link

enwired commented Feb 2, 2018

My project already uses Hikari CP. When I upgraded Quartz from 2.2.2 to 2.3.0, it started breaking in strange ways. It was very difficult for me to track down the problem.

It turns out that this is because Quartz now includes dependence on HikariCP-java6-2.3.13, but I want to be using the more recent, java8 version, HikariCP-2.7.2.

I suppose I can add an "exclusion" when importing Quartz via Maven and then manually add my own version of Hikari. But will this break Quartz?

@zemian
Copy link
Contributor

zemian commented Dec 27, 2018

For those who still have issues with HirakiCP, you can see #294 for solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants