Reputation: 817
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:
?ApplicationName=<name>
to the JDBC url.System.setProperty("oracle.jdbc.v$session.program", <name>)
spring.datasource.hikari.data-source-properties.v$session.program: <name>
in the application.ymlUpvotes: 8
Views: 8056
Reputation: 440
For spring application using properties based configuration following syntax worked for me.
spring.datasource.hikari.data-source-properties=v$session.program=your_app_name
Somewhat weird syntax, but it worked for me in OracleDB
& SpringBoot v2.6
Upvotes: 2
Reputation: 106
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}
Upvotes: 2
Reputation: 61
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
Upvotes: 6
Reputation: 44970
Using HikariCP pool properties (default pool in Spring Boot 2)
spring:
datasource:
hikari:
data-source-properties:
v$session.program: MyAppName
Upvotes: 1