4

I am getting connection is not available error msg with below config xml mapping.Please suggest me what i am doing wrong in beolw code or this is some another issue. As per my investigation this is an intregation issue with HikariCP, Hibernate and Spring Batch. 2.0.3 5.1.6 4.0.0.RELEASE 3.0.0.RELEASE 3.0.0.RELEASE 0.5 2.3.2 4.3.5.Final

Below Configuration
    @Bean
    public DataSource dataSource() {
        final HikariConfig config = new HikariConfig();
        config.setMaximumPoolSize(1);
        System.out.println("Pool size is "+config.getMaximumPoolSize());
        config.setDriverClassName(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
        config.setJdbcUrl(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
        config.setUsername(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
        config.setPassword(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));

        final HikariDataSource dataSource = new HikariDataSource(config);
        return dataSource;
    }

Error:--

DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Timeout failure stats (total=1, active=1, idle=0, waiting=0)
2017-01-03T11:10:30.33+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:10:30.335 [task-scheduler-6] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: null
2017-01-03T11:10:30.33+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:10:30.335 [task-scheduler-6] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - HikariPool-1 - Connection is not available, request timed out after 30000ms.
2017-01-03T11:10:30.34+0000 [App/0]      OUT In finally If
2017-01-03T11:10:43.89+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:10:43.896 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=1)
2017-01-03T11:11:00.34+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:11:00.340 [task-scheduler-6] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Timeout failure stats (total=1, active=1, idle=0, waiting=0)
2017-01-03T11:11:00.34+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:11:00.341 [task-scheduler-6] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: null
2017-01-03T11:11:00.34+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:11:00.341 [task-scheduler-6] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - HikariPool-1 - Connection is not available, request timed out after 30000ms.
2017-01-03T11:11:00.35+0000 [App/0]      OUT PDC::fre-staging/0: 2017-01-03 11:11:00.354 [task-scheduler-6] ERROR o.s.batch.core.step.AbstractStep - Encountered an error executing step emisTopupStep in job emisTopupJob
2017-01-03T11:11:00.35+0000 [App/0]      OUT javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection.

Please help me out.

AxelH
  • 14,325
  • 2
  • 25
  • 55
raman kumar
  • 41
  • 1
  • 3
  • Don't know `Hikari` but can you ping your remote server ? – AxelH Jan 03 '17 at 12:07
  • Answered here, this answer might help to resolve your issue, https://stackoverflow.com/questions/47758091/hikaripool-1-connection-is-not-available-request-timed-out-after-30000ms-for/57647811#57647811 – Girdhar Singh Rathore Aug 25 '19 at 16:36

1 Answers1

2

You are setting the pool max size to 1 with the line config.setMaximumPoolSize(1); My guess is that is your problem. Try increasing it, just don't over do it. The defaults is 10 which is good for most cases.

rmunix
  • 21
  • 3