Spring Boot auto-config and Oracle statement caching

941 views
Skip to first unread message

Tommy Ludwig

unread,
Dec 1, 2016, 3:24:13 AM12/1/16
to HikariCP
Has anyone been able to get Oracle statement caching configured through HikariCP when using Spring Boot's auto-configuration?

I was just trying now and it seems like setting the following should work (jdbcUrl, username, and password omitted).

spring:
  datasource
:
    hikari:
      data-source-properties:
        maxStatements: 10
       
implicitCachingEnabled: true
   
type: com.zaxxer.hikari.HikariDataSource

However, I think because Spring Boot sets the driver-class-name (as oracle.jdbc.OracleDriver) that the data-source-properties are not having effect as expected.
I have debugged and confirmed that HikariDataSource.dataSourceProperties has the following:

0 = {Hashtable$Entry@9290} "maxStatements" -> "10"
1 = {Hashtable$Entry@9291} "implicitCachingEnabled" -> "true"

Also in the HikariPool.dataSource.driverProperties there is the following:

0 = {Hashtable$Entry@9326} "user" -> "***"
1 = {Hashtable$Entry@9327} "maxStatements" -> "10"
2 = {Hashtable$Entry@9328} "password" -> "***"
3 = {Hashtable$Entry@9329} "implicitCachingEnabled" -> "true"

But even with this, the implicit statement cache is not enabled, it seems.

Code:
try (Connection conn = ds.getConnection()) {
OracleConnection oconn = conn.unwrap(OracleConnection.class);
System.out.println("statement caching? " + oconn.getImplicitCachingEnabled());
}

Output:
statement caching? false


Judging from Oracle's documentation (http://docs.oracle.com/database/121/JJDBC/stmtcach.htm), perhaps statement caching can only be configured on OracleDataSource.
Since Spring Boot's auto-configuration sets the driver-class-name, if I set the data-source-class-name also, HikariCP will throw an exception because both are set:

Caused by: java.lang.IllegalStateException: cannot use driverClassName and dataSourceClassName together.


Of course I can instantiate HikariDataSource by myself and set things so it will work, but I would have to do this in every project, which is why I wanted to find a way to do it using the auto-configuration provided by Spring Boot.
Has anyone gotten this to work or have ideas what to do?

Thank you in advance for any help and time spent on this.

Tommy

Brett Wooldridge

unread,
Dec 19, 2016, 10:00:15 AM12/19/16
to HikariCP
This is a Spring Boot limitation, please file a bug in their issue tracker.

-Brett

Reply all
Reply to author
Forward
0 new messages