Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

We Are Going To Discuss About Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot. So lets Start this Java Article.

Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

  1. Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

    The problem is that the default value of the spring.datasource.hikari.maxLifetime (30 minutes – https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) is higher than the database's “wait_timeout” (10 minutes in my case).
    So you have two options, either decrease the hikari.maxLifetime below 10 minutes, or increase the database's “wait_timeout” property.

  2. Possibly consider using a shorter maxLifetime value – hikari connection pool spring boot

    The problem is that the default value of the spring.datasource.hikari.maxLifetime (30 minutes – https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) is higher than the database's “wait_timeout” (10 minutes in my case).
    So you have two options, either decrease the hikari.maxLifetime below 10 minutes, or increase the database's “wait_timeout” property.

Solution 1

The problem is that the default value of the spring.datasource.hikari.maxLifetime (30 minutes – https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) is higher than the database’s “wait_timeout” (10 minutes in my case).
So you have two options, either decrease the hikari.maxLifetime below 10 minutes, or increase the database’s “wait_timeout” property.

Original Author Of This Content

Solution 2

You can set value as below in application.properties file

spring.datasource.hikari.maxLifeTime : 600000 #10 minutes wait time

Original Author Of This Content

Solution 3

In my case, I solved the problem through this setting

@Configuration
public class HikariSetting{

    @Bean
    public HikariConfig config() {
        HikariConfig hikariConfig = new HikariConfig();
        
        // other setting
        
        hikariConfig.addDataSourceProperty("socketTimeout", 600000);
        hikariConfig.setMaxLifetime(600000);
        
        return hikariConfig;
    }
    
}

reference this

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment