Skip to content

Commit dc39615

Browse files
committed
Recipe and README updates
1 parent 1a48118 commit dc39615

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

recipes/hikari-ucp/README.md

+78-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,80 @@
1-
# Hikari to UCP Open Rewrite Recipe
1+
# Hikari to UCP Open Rewrite Recipe
2+
3+
Current Version is `0.0.1-SNAPSHOT` and is under development. Please file GitHub issues for issues, enhancements and more.
4+
5+
## Hikari to UCP rewrite Recipe
6+
7+
> **_NOTE:_** In the pre release the rewrite works best with `properties` files. `YAML` files works too but the formatting of the outcome isn't pretty.
8+
9+
This recipe will change the Hikare connection pool parameters and dependency from Hikari to Oracle Universal Connection Pooling (UCP). The [UCP documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/jjucp/index.html).
10+
11+
The following properties are rewritten:
12+
13+
### Maven dependencies `pom.xml
14+
15+
The Hikari dependency is removed and replaced with SPring Boot starters for Oracle UCP and Oracle Wallet (commonly used to connect to an autonomous database (ADB)).
16+
17+
```xml
18+
<dependency>
19+
<groupId>com.zaxxer</groupId>
20+
<artifactId>HikariCP</artifactId>
21+
</dependency>
22+
```
23+
24+
is changed to:
25+
26+
```xml
27+
<dependency>
28+
<groupId>com.oracle.database.spring</groupId>
29+
<artifactId>oracle-spring-boot-starter-ucp</artifactId>
30+
<version>25.1.0</version>
31+
</dependency>
32+
```
33+
34+
And the following dependency is added, as it is commonly used to connect to an autonomous database (ADB):
35+
36+
```xml
37+
<dependency>
38+
<groupId>com.oracle.database.spring</groupId>
39+
<artifactId>oracle-spring-boot-starter-wallet</artifactId>
40+
<version>25.1.0</version>
41+
</dependency>
42+
```
43+
44+
### Spring Boot Connection Pooling configuration `application.properties`
45+
46+
> **_NOTE:_** The recipe will change Hikari's milliseconds to seconds.
47+
48+
The following properties are rewritten. [UCP documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/jjucp/index.html)
49+
50+
| Hikari Property | Oracle UCP Property | Notes |
51+
|-----------------|---------------------|-------|
52+
| N/A | `spring.datasource.driver-class-name` | Will be set to `oracle.jdbc.OracleDriver` |
53+
| N/A | `spring.datasource.type` | Will be set to `oracle.ucp.jdbc.PoolDataSource` |
54+
| `spring.datasource.hikari.pool-name` | `spring.datasource.oracleucp.connection-pool-name` | |
55+
| `spring.datasource.hikari.maximum-pool-size` | `spring.datasource.oracleucp.max-pool-size` | |
56+
| `spring.datasource.hikari.minimum-idle` | `spring.datasource.oracleucp.min-pool-size` | |
57+
| `spring.datasource.hikari.connection-timeout` | `spring.datasource.oracleucp.connection-wait-timeout` | |
58+
| `spring.datasource.hikari.idle-timeout` | `spring.datasource.oracleucp.inactive-connection-timeout` | |
59+
| `spring.datasource.hikari.connection-test-query` | `spring.datasource.oracleucp.s-q-l-for-validate-connection` | |
60+
| `spring.datasource.hikari.max-lifetime` | `spring.datasource.oracleucp.max-connection-reuse-time` | |
61+
| `spring.datasource.hikari.validation-timeout` | `pring.datasource.oracleucp.connection-validation-timeout` | |
62+
63+
The following UCP properties are added:
64+
65+
| Oracle UCP Property | Value | Notes |
66+
|---------------------|-------|-------|
67+
| `spring.datasource.oracleucp.initial-pool-size` | 5 | [UCP documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/jjucp/index.html) |
68+
69+
The following Hikari Properties do not have identical UCP properties and will be commented out in the rewritten properties file. [UCP documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/jjucp/index.html)
70+
71+
| Hikari UCP Property | Notes |
72+
|---------------------|-------|
73+
| `spring.datasource.hikari.auto-commit` | Use Oracle JDBC driver connection property autoCommit |
74+
| `spring.datasource.hikari.register-mbeans` | UCP always attempts registration |
75+
| `spring.datasource.hikari.thread-factory` | UCP supports setTaskManager instead |
76+
| `spring.datasource.hikari.scheduled-executor` | UCP supports setTaskManager instead |
77+
| `spring.datasource.hikari.keepalive-time` | Closest is to use driver connection properties oracle.net.keepAlive + oracle.net.TCP_KEEPIDLE |
278

379
## Build the Open Rewrite Recipe
480

@@ -36,4 +112,4 @@ mvn install
36112
</plugins>
37113
</build>
38114
</project>
39-
```
115+
```

recipes/hikari-ucp/src/main/resources/META-INF/rewrite/rewrite.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ recipeList:
2323
- org.openrewrite.java.dependencies.AddDependency:
2424
groupId: com.oracle.database.spring
2525
artifactId: oracle-spring-boot-starter-ucp
26-
version: 25.0.0
26+
version: 25.1.0
27+
- org.openrewrite.java.dependencies.AddDependency:
28+
groupId: com.oracle.database.spring
29+
artifactId: oracle-spring-boot-starter-wallet
30+
version: 25.1.0
2731

2832
# spring.datasource.oracleucp.connection-factory-class: oracle.jdbc.pool.OracleDataSource
2933
- org.openrewrite.java.spring.ChangeSpringPropertyKey:

0 commit comments

Comments
 (0)