|
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 | |
2 | 78 |
|
3 | 79 | ## Build the Open Rewrite Recipe
|
4 | 80 |
|
@@ -36,4 +112,4 @@ mvn install
|
36 | 112 | </plugins>
|
37 | 113 | </build>
|
38 | 114 | </project>
|
39 |
| -``` |
| 115 | +``` |
0 commit comments