venkat
venkat

Reputation: 13

Disabling Spring Boot 2 Autocommit Hikari

I am using hikari connection pool with JPA hibernate. I want to disable autocommit feature during read operations while interacting with DB.

Added spring.datasource.hikari.auto-commit=false property. After adding this property in application.properties, getting the below error during startup.

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target HikariDataSource (HikariPool-1) failed:

    Property: spring.datasource.hikari.autoCommit
    Value: false
    Reason: Property 'autoCommit' threw exception; nested exception is java.lang.IllegalStateException: The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes.


Action:

Update your application's configuration

Hikari version: 3.2.0

Springboot verison : 1.5.14-RELEASE

Upvotes: 1

Views: 1321

Answers (1)

times29
times29

Reputation: 3373

Try adding the following Hibernate config:

spring:
  jpa:
    properties:
      hibernate:
        connection:
          provider_disables_autocommit: true

More information regarding this setting can be found in Vlad Mihalcea's blog.

Upvotes: 0

Related Questions