This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (c) 2024, Oracle and/or its affiliates. | |
This software is dual-licensed to you under the Universal Permissive License | |
(UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License | |
2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose | |
either license. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
https://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.datasource.url=<YOUR_JDBC_CONNECTION_URL> | |
spring.datasource.username=<YOUR_DB_USERNAME> | |
spring.datasource.password=<YOUR_DB_PASSWORD> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.datasource.type=oracle.ucp.jdbc.PoolDataSource | |
spring.datasource.oracleucp.connection-pool-name=connectionPoolName1 | |
spring.datasource.oracleucp.initial-pool-size=1 | |
spring.datasource.oracleucp.min-pool-size=1 | |
spring.datasource.oracleucp.max-pool-size=2 | |
spring.datasource.oracleucp.connection-factory-class-name=oracle.jdbc.pool.OracleDataSource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HikariCP metrics | UCP Metrics | |
---|---|---|
Number of active connections | BorrowedConnectionsCount | |
Number of pending connection requests | PendingRequestsCount | |
Total number of timed-out requests | CumulativeFailedConnectionWaitCount | |
Time taken to get a connection | PeakConnectionWaitTime / AverageConnectionWaitTime | |
Current total number of connections | TotalConnectionsCount | |
Number of idle connections | AvailableConnectionsCount | |
Max number of connections | PeakConnectionsCount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UCP Knob | Description | |
---|---|---|
UCP[XA]ConnectionBuilder.user().password() or PoolDataSource.getConnection(user + password) | UCP's single pool can hold connections from more than one database accounts and can borrow a connection to a given account. | |
UCP[XA]ConnectionBuilder.shardingKey().superShardingKey() | It is possible to establish a connection with a given sharding key/super key. | |
UCP[XA]ConnectionBuilder.connectionWaitTimeout() or UCP[XA]ConnectionBuilder.connectionWaitDuration() | UCP can set connection wait timeout (either in seconds or in Duration - supporting milliseconds) for a separate borrow request as well as for a whole PoolDataSource. | |
UCP[XA]ConnectionBuilder.service() | It is possible to borrow a connection to a selected database service (a pool can hold connections from different services. | |
UCP[XA]ConnectionBuilder..labels() or PoolDataSource.getConnection(labels) | UCP connections can be labeled and per-label connection cost can be assigned. Then a connection can be borrowed based on its label(s) and cost. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HikariCP | Comments | |
---|---|---|
autoCommit | Use Oracle JDBC driver connection property autoCommit. | |
registerMbeans | UCP always attempts registration. | |
threadFactory | UCP supports setTaskManager instead (setter API only). | |
scheduledExecutor | UCP supports setTaskManager instead (setter API only). | |
keepaliveTime | Closest is to use driver connection properties oracle.net.keepAlive + oracle.net.TCP_KEEPIDLE which apply to all connections borrowed/available. The HikariCP property applies only to idle/available connections and uses isValid/query to keep alive. Another option is to add async validation in UCP for available connections. | |
minimumIdle | Controls the minimum number of idle connections HikariCP tries to maintain in the pool. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HikariCP | UCP | Comments | |
---|---|---|---|
dataSourceClassName | ConnectionFactoryClassName | (1) ConnectionFactoryClassName also covers java.sql.DriverManager cases.(2) HikariCP doesn't support XA. | |
jdbcUrl | URL | ||
username | User | ||
password | Password | ||
connectionTimeout (ms) | ConnectionWaitTimeout | UCP 23.2 supports ms and pre-23.2 supports sec. HikariCP lowest acceptable value 250ms. | |
idleTimeout | InactiveConnectionTimeout | HikariCP won't drop below minimumIdle. | |
maxLifeTime | MaxConnectionReuseTime | ||
connectionTestQuery | SQLForValidateConnection | ||
maximumPoolSize | MaxPoolSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oracle.dev.jdbc.r2dbc; | |
import io.r2dbc.spi.Connection; | |
import io.r2dbc.spi.ConnectionFactory; | |
import reactor.core.publisher.Flux; | |
import reactor.core.publisher.Mono; | |
public class OracleR2dbcProjectReactor { | |
private static final String QUERY = "SELECT * FROM CUSTOMERS"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.oracle.jdbc.reactive; | |
import java.sql.SQLException; | |
import java.util.concurrent.Flow; | |
import oracle.jdbc.OracleConnection; | |
import oracle.jdbc.OraclePreparedStatement; | |
import oracle.jdbc.pool.OracleDataSource; | |
public class SQLStatementWithAsynchronousJDBC { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER ORACLE_23C_USER IDENTIFIED BY <YOUR_PASSWORD>; | |
GRANT DB_DEVELOPER_ROLE TO ORACLE_23C_USER; | |
GRANT CREATE SESSION TO ORACLE_23C_USER; | |
GRANT UNLIMITED TABLESPACE TO ORACLE_23C_USER; | |
CREATE TABLE Employee | |
(id NUMBER(10) CONSTRAINT pk_employee PRIMARY KEY, | |
name VARCHAR2(20), | |
job VARCHAR2(20), | |
salary NUMBER(10), |
NewerOlder