1
+ #
2
+ # Copyright © 2025, Oracle and/or its affiliates.
3
+ # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4
+ #
5
+ # Source for the recipe:
6
+ # https://github.com/brettwooldridge/HikariCP?tab=readme-ov-file#gear-configuration-knobs-baby
7
+ ---
8
+ type : specs.openrewrite.org/v1beta/recipe
9
+ name : oracle.com.cloud.recipes.hikariucp.ConvertHikariToUCP
10
+ displayName : Migrate Hikari CP to Oracle UCP
11
+ description : Migrate Hikari Connection Pool to Oracle Universal Connection Pool
12
+ tags :
13
+ - spring
14
+ - oracle
15
+ - ucp
16
+ - hikari
17
+ recipeList :
18
+
19
+ # For pom.xml
20
+ - org.openrewrite.java.dependencies.RemoveDependency :
21
+ groupId : com.zaxxer*
22
+ artifactId : HikariCP*
23
+ - org.openrewrite.java.dependencies.AddDependency :
24
+ groupId : com.oracle.database.spring
25
+ artifactId : oracle-spring-boot-starter-ucp
26
+ version : 25.0.0
27
+
28
+ # spring.datasource.oracleucp.connection-factory-class: oracle.jdbc.pool.OracleDataSource
29
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
30
+ oldPropertyKey : spring.datasource.hikari.data-source-class-name
31
+ newPropertyKey : spring.datasource.oracleucp.connection-factory-class-name
32
+ - org.openrewrite.java.spring.ChangeSpringPropertyValue :
33
+ propertyKey : spring.datasource.oracleucp.connection-factory-class-name
34
+ newValue : oracle.jdbc.pool.OracleDataSource
35
+
36
+ # spring.datasource.driver-class-name: OracleDriver
37
+ - org.openrewrite.java.spring.ChangeSpringPropertyValue :
38
+ propertyKey : spring.datasource.driver-class-name
39
+ newValue : oracle.jdbc.OracleDriver
40
+
41
+ # spring.datasource.type: oracle.ucp.jdbc.PoolDataSource
42
+ - org.openrewrite.java.spring.ChangeSpringPropertyValue :
43
+ propertyKey : spring.datasource.type
44
+ newValue : oracle.ucp.jdbc.PoolDataSource
45
+
46
+ # spring.datasource.oracleucp.connection-pool-name
47
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
48
+ oldPropertyKey : spring.datasource.hikari.pool-name
49
+ newPropertyKey : spring.datasource.oracleucp.connection-pool-name
50
+
51
+ # spring.datasource.oracleucp.max-pool-size
52
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
53
+ oldPropertyKey : spring.datasource.hikari.maximum-pool-size
54
+ newPropertyKey : spring.datasource.oracleucp.max-pool-size
55
+
56
+ # spring.datasource.oracleucp.min-pool-size
57
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
58
+ oldPropertyKey : spring.datasource.hikari.minimum-idle
59
+ newPropertyKey : spring.datasource.oracleucp.min-pool-size
60
+
61
+ # spring.datasource.oracleucp.connection-validation-timeout
62
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
63
+ oldPropertyKey : spring.datasource.hikari.connection-timeout
64
+ newPropertyKey : spring.datasource.oracleucp.connection-wait-timeout
65
+
66
+ # spring.datasource.oracleucp.inactive-connection-timeout
67
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
68
+ oldPropertyKey : spring.datasource.hikari.idle-timeout
69
+ newPropertyKey : spring.datasource.oracleucp.inactive-connection-timeout
70
+
71
+ # spring.datasource.oracleucp.s-q-l-for-validate-connection
72
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
73
+ oldPropertyKey : spring.datasource.hikari.connection-test-query
74
+ newPropertyKey : spring.datasource.oracleucp.s-q-l-for-validate-connection
75
+
76
+ # spring.datasource.oracleucp.max-connection-reuse-time
77
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
78
+ oldPropertyKey : spring.datasource.hikari.max-lifetime
79
+ newPropertyKey : spring.datasource.oracleucp.max-connection-reuse-time
80
+
81
+ # spring.datasource.oracleucp.max-connection-reuse-time
82
+ - org.openrewrite.java.spring.ChangeSpringPropertyKey :
83
+ oldPropertyKey : spring.datasource.hikari.validation-timeout
84
+ newPropertyKey : spring.datasource.oracleucp.connection-validation-timeout
85
+
86
+ # spring.datasource.oracleucp.initial-pool-size
87
+ - org.openrewrite.java.spring.AddSpringProperty :
88
+ property : spring.datasource.oracleucp.initial-pool-size
89
+ value : 5
90
+ comment : " Specifies the number of available connections created after the pool is initiated"
91
+
92
+ # HikariCP properties that don’t have identical UCP properties
93
+ - org.openrewrite.java.spring.CommentOutSpringPropertyKey :
94
+ propertyKey : spring.datasource.hikari.auto-commit
95
+ comment : " Use Oracle JDBC driver connection property autoCommit."
96
+ - org.openrewrite.java.spring.CommentOutSpringPropertyKey :
97
+ propertyKey : spring.datasource.hikari.register-mbeans
98
+ comment : " UCP always attempts registration."
99
+ - org.openrewrite.java.spring.CommentOutSpringPropertyKey :
100
+ propertyKey : spring.datasource.hikari.thread-factory
101
+ comment : " UCP supports setTaskManager instead."
102
+ - org.openrewrite.java.spring.CommentOutSpringPropertyKey :
103
+ propertyKey : spring.datasource.hikari.scheduled-executor
104
+ comment : " UCP supports setTaskManager instead."
105
+ - org.openrewrite.java.spring.CommentOutSpringPropertyKey :
106
+ propertyKey : spring.datasource.hikari.keepalive-time
107
+ comment : " Closest is to use driver connection properties oracle.net.keepAlive + oracle.net.TCP_KEEPIDLE"
108
+
109
+ # Convert milliseconds to seconds
110
+ - oracle.com.cloud.recipes.hikariucp.ConvertMsToSecondsInPropertiesRecipe :
111
+ keyRegex : ' spring\.datasource\.hikari\.(connectionTimeout|idleTimeout|maxLifetime|leakDetectionThreshold)'
112
+ - oracle.com.cloud.recipes.hikariucp.ConvertMsToSecondsInYamlRecipe :
113
+ pathRegex : ' spring\.datasource\.hikari\.(connectionTimeout|idleTimeout|maxLifetime|leakDetectionThreshold)'
0 commit comments