I have two datasources in a Spring Boot application. I want to set the autocommit to false, however it's only setting one connection to false, at least per the logging the logging for the Hikari connection pool. Somehow Spring takes the datasource wraps it into this Hikari connection but leaves me scratching my head as to which one it did that for.
I'd like to know how, in my application.properties file, I can set the autocommit to all of my datasources. Bonus points to tell me how to name the connection pool that the datasource gets wrapped into.
Below is the application.properties:
spring.datasource.url=${BLUECOST_DATASOURCE_URL}
spring.datasource.username=${BLUECOST_DATASOURCE_USERNAME}
spring.datasource.password=${BLUECOST_DATASOURCE_PASSWORD}
spring.datasource.driver-class-name=${BLUECOST_DATASOURCE_DRIVER}
spring.datasource.auto-commit=false
spring.batch-datasource.url=${BATCH_DATASOURCE_URL}
spring.batch-datasource.username=${BATCH_DATASOURCE_USERNAME}
spring.batch-datasource.password=${BATCH_DATASOURCE_PASSWORD}
spring.batch-datasource.driver-class-name=${BATCH_DATASOURCE_DRIVER}
spring.batch-datasource.jpa
spring.batch-datasource.auto-commit=false
spring.jpa.database-platform=DB2
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DB2Dialect
spring.jpa.properties.hibernate.default_schema=${cost.rules.schema}
Logging snippet:
2021-09-11 23:38:07,431 INFO [https-jsse-nio-8448-exec-7]: com.ibm.cio.sprint.cost.rules.resource.SoftLayerController Received getAsyncUploadSoftLayerFile request job instance id=33 job execution id=33
2021-09-11 23:38:07,432 INFO [https-jsse-nio-8448-exec-7]: com.ibm.cio.sprint.cost.rules.application.SoftLayerJobService Looking for status of job instance id 33 job execution id
2021-09-11 23:38:07,432 DEBUG [https-jsse-nio-8448-exec-7]: org.springframework.jdbc.core.JdbcTemplate Executing prepared SQL query
2021-09-11 23:38:07,433 DEBUG [https-jsse-nio-8448-exec-7]: org.springframework.jdbc.core.JdbcTemplate Executing prepared SQL statement [SELECT JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION from BLUECOST.BATCH_JOB_INSTANCE where JOB_INSTANCE_ID = ?]
2021-09-11 23:38:07,433 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig HikariPool-2 - configuration:
2021-09-11 23:38:07,434 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig allowPoolSuspension.............false
2021-09-11 23:38:07,435 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig autoCommit......................true
2021-09-11 23:38:07,435 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig catalog.........................none
2021-09-11 23:38:07,435 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig connectionInitSql...............none
2021-09-11 23:38:07,435 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig connectionTestQuery.............none
2021-09-11 23:38:07,436 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig connectionTimeout...............30000
2021-09-11 23:38:07,436 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig dataSource......................none
2021-09-11 23:38:07,436 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig dataSourceClassName.............none
2021-09-11 23:38:07,437 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig dataSourceJNDI..................none
2021-09-11 23:38:07,437 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig dataSourceProperties............{password=<masked>}
2021-09-11 23:38:07,437 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig driverClassName................."com.ibm.db2.jcc.DB2Driver"
2021-09-11 23:38:07,437 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig healthCheckProperties...........{}
2021-09-11 23:38:07,438 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig healthCheckRegistry.............none
2021-09-11 23:38:07,438 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig idleTimeout.....................600000
2021-09-11 23:38:07,438 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig initializationFailTimeout.......1
2021-09-11 23:38:07,439 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig isolateInternalQueries..........false
2021-09-11 23:38:07,439 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig jdbcUrl.........................jdbc:db2://<omitted>;
2021-09-11 23:38:07,440 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig leakDetectionThreshold..........0
2021-09-11 23:38:07,440 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig maxLifetime.....................1800000
2021-09-11 23:38:07,440 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig maximumPoolSize.................10
2021-09-11 23:38:07,441 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig metricRegistry..................none
2021-09-11 23:38:07,441 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig metricsTrackerFactory...........none
2021-09-11 23:38:07,442 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig minimumIdle.....................10
2021-09-11 23:38:07,442 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig password........................<masked>
2021-09-11 23:38:07,443 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig poolName........................"HikariPool-2"
2021-09-11 23:38:07,443 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig readOnly........................false
2021-09-11 23:38:07,444 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig registerMbeans..................false
2021-09-11 23:38:07,444 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig scheduledExecutor...............none
2021-09-11 23:38:07,445 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig schema..........................none
2021-09-11 23:38:07,445 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig threadFactory...................internal
2021-09-11 23:38:07,445 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig transactionIsolation............default
2021-09-11 23:38:07,446 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig username........................"90529100"
2021-09-11 23:38:07,446 DEBUG [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariConfig validationTimeout...............5000
2021-09-11 23:38:07,446 INFO [https-jsse-nio-8448-exec-7]: com.zaxxer.hikari.HikariDataSource HikariPool-2 - Starting...
I tried setting default-auto-commit to false, but Hikari still built an autocommit to true
I looked on SO at question: Spring Boot 2 disable Autocommit Hikari with multiple datasources, and I tried some of the suggestions mentioned, except this one:
"...long story short make sure that you add .type(HikariDataSource.class) before you build your class." I don't know what they meant by that. Is that some application.properties change or some Spring annotation change?
Thanks, Woodsman