6

I have a Spring Boot 1.4.7 application that I am currently updating to version 2.0.5. The application connects to an Oracle DB using JDBC using the following configuration:

spring:
  jpa:
    database-platform: org.hibernate.dialect.Oracle12cDialect
  datasource:
    url: jdbc:oracle:thin:@<db_server>
    username: ${credentials.database.username}
    password: ${credentials.database.password}
    driver-class: oracle.jdbc.OracleDriver.class
    platform: oracle
    tomcat:
      connection-properties: v$session.program=${spring.application.name}

After updating the application to Spring Boot 2.0.5 the application name sent to the server is JDBC Thin Client instead of ${spring.application.name}. The reason for this seems to be the switch to HikariCP as the default connection pool in Spring 2.x. How would I migrate this configuration to Hikari in a way that allows me to send a custom property for v$session.program to the db?

What I have tried:

  • Appending ?ApplicationName=<name> to the JDBC url.
  • Solutions mentioned in this Stackoverflow question
  • Setting System.setProperty("oracle.jdbc.v$session.program", <name>)
  • Setting spring.datasource.hikari.data-source-properties.v$session.program: <name> in the application.yml
Joba
  • 777
  • 7
  • 24
  • Thanks a lot ! This helped my a lot when I tried to set `defaultRowPrefetch` which makes Oracle ojdbc8.jar connections run much more efficiently ! – Marged Oct 28 '18 at 10:08

3 Answers3

4

In yaml, the dollar sign is escaped.

spring.datasource.hikari.data-source-properties.v$session.program: <name>

com.zaxxer.hikari.HikariConfig : dataSourceProperties............{password=<masked>, vsession.program=<name>}

Try this.

spring:
  datasource:
    hikari:
      data-source-properties: v$session.program=name
2

If you want to reference to spring.application.name you have to use it like this:

spring:
  datasource:
    hikari:
      data-source-properties:
        "[v$session.program]": ${spring.application.name}
twonky
  • 106
  • 3
1

Using HikariCP pool properties (default pool in Spring Boot 2)

spring:
  datasource:
    hikari:
      data-source-properties:
        v$session.program: MyAppName
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111