0% found this document useful (0 votes)
11 views19 pages

HikariCP Best Practices for Oracle DB

This blog post outlines best practices for configuring HikariCP with Spring Boot for Oracle Database, focusing on leveraging high availability features. It provides detailed steps for setting up HikariCP, including dependency management, application properties configuration, and enabling high availability through Oracle RAC. Additionally, it discusses the importance of connection validation and request boundaries for efficient connection management during planned and unplanned outages.

Uploaded by

OscarRamirez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views19 pages

HikariCP Best Practices for Oracle DB

This blog post outlines best practices for configuring HikariCP with Spring Boot for Oracle Database, focusing on leveraging high availability features. It provides detailed steps for setting up HikariCP, including dependency management, application properties configuration, and enabling high availability through Oracle RAC. Additionally, it discusses the importance of connection validation and request boundaries for efficient connection management during planned and unplanned outages.

Uploaded by

OscarRamirez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HikariCP Best Practices for Oracle Database and Spring Boot [Link]

Developers Blog

1 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

December 4, 2024 | 17 minute read

Kuassi Mensah
Director Product Management

Richard Exley
Consulting Member of Technical Sta�, Oracle Database

Irina Granat
Senior Director

 殺  
This previously published blog now covers the new release and
updates. The earlier version of the blog can be reviewed here.

HikariCP is a popular Java connection pool, commonly used with Spring Boot. This blog post furnishes
the best practices for con�guring HikariCP with Spring Boot for the Oracle Database.

You will learn how to con�gure HikariCP to leverage the Oracle Databases’ High Availability (HA)
capabilities for continuous service during planned and unplanned downtime. In this blog, we will cover
(beginRequest and endRequest
API support) that are part of the JDBC 4.3 standard. The request boundaries enable HikariCP to
transparently inject BeginRequest and EndRequest, similarly to UCP, thereby enabling the JDBC driver
to perform replay as part of Transparent Application Continuity (TAC).
All the recommendations in this blog post have been tested using the latest Long Term Support (LTS)
Oracle Database release i.e., and

Before zooming into HikariCP, a few words about the Universal Connection Pool (UCP). The Oracle
Database furnishes the Universal Connection Pool (UCP), a feature-rich Java connection pool — one of
the Spring Boot choices — that supports out-of-the-box, all Oracle database con�gurations, and
mission-critical capabilities such as Oracle Real Application Cluster (RAC), Data Guard, Oracle
Sharding, Asynchronous API, Runtime Load Balancing, XA, and front-end to Database Resident
Connection Pool (DRCP).

UCP is released quarterly and fully supported by Oracle.


See more details at: h�ps://[Link]/jdbc/

2 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

You may have standardized on HikariCP and do not necessarily need the advanced and mission-
critical UCP features. However, if you’d like to migrate from HikariCP to UCP, this blog post is for you.

The basic steps for using HikariCP with the Oracle Database consist of (i) con�guring the Oracle JDBC
driver, and (ii) con�guring HikariCP.

Add Oracle Driver as a dependency in Spring Initializer or manually add it to your project’s [Link].

the version of JDBC is [Link].10:

Copy code snippet

<properties>
<[Link]>[Link].10</<[Link]>
</properties>

<dependencies>
...
<dependency>
<groupId>[Link]</groupId>
<artifactId>ojdbc11</artifactId>
<version>${[Link]}</version>
</dependency>
...
</dependencies>

the version of JDBC is [Link]:

Copy code snippet

<properties>
<[Link]>[Link]</<[Link]>
</properties>

<dependencies>
...
<dependency>
<groupId>[Link]</groupId>
<artifactId>ojdbc8</artifactId>
<version>${[Link]}</version>
</dependency>
...
</dependencies>

3 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

Use this page for more information on Oracle RDBMS and JDK Version Compatibility for Oracle JDBC
Drivers.

1. Starting with version 2, Spring Boot uses HikariCP as the default connection pool and it is transitively
imported with the following Spring Boot starters: spring-boot-starter-jdbc or spring-boot-
starter-data-jpa.

Copy code snippet

<parent>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
...
<dependency>
<! -- Assume Spring Data JDBC -->
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
...
</dependencies>

2. However, in order to use the latest HikariCP release (i.e., version 6.0.0 as of this writing) which
implements request boundaries option, we also need to add the Hikari dependency in
the [Link] explicitly:

Copy code snippet

<dependencies>
...
<dependency>
<groupId>[Link]</groupId>
<artifactId>HikariCP</artifactId>
<version>6.0.0</version>
</dependency>
...
</dependencies>

3. Then con�gure the application properties using one of the following methods: using
�le (Spring Boot automatically reads these �les and applies the

4 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

[Link] �le (Spring Boot automatically reads these �les and applies the
con�guration), creating a con�guration class annotated with @Con�guration and using @Bean to
de�ne the DataSource bean with HikariCP se�ings — we are using this method hereafter, using
[Link] �le, and using a Kubernetes secret, for a more secure method. See this UCP-
related blog post for more details about the approaches. Pick the approach that best �ts your project
and preferences. The �rst method might be simpler and is often su�cient for basic setups, while the
second method provides more �exibility and control over the con�guration in a Java class.

HikariCP has default se�ings that perform well in most deployments without additional tweaking.
Spring Boot exposes Hikari-speci�c properties using the [Link] namespace.
Every property is optional except for the few essential ones that must be set. HikariCP’s o�cial GitHub
page explains various con�guration options. In addition, you can review the Common Application
Properties page listing all Spring Boot [Link] options.

Here are the examples of and

An [Link] with the minimum set of properties required for using the Oracle
Database.

Copy code snippet

#Oracle Database - Connection Details


[Link]=${JDBC_URL}
[Link]=${DB_USER}
[Link]=${DB_PASSWORD}
[Link]-class-name=[Link]

# HikariCP settings
[Link]-pool-size=4
[Link]-idle=4
[Link]

In this example we enabled the following HikariCP properties:

→ sets the maximum number of connections that


can be held in the connection pool
→ de�nes the minimum number of idle connections that
the pool should try to maintain. An idle connection is one that is not in use but is kept ready and in
open state. Maintaining idle connections can improve the performance of the applications as it will
reduce the time taken to acquire a new connection.
→ speci�es how much e�ort to put into validating a
connection on borrow. The values range from NONE (least e�ort) to COMPLETE (most e�ort).
Default is NETWORK, which is very expensive and so it should be changed unless it is the best for
your application. Se�ing the [Link] property to
enables lightweight connection validation by the JDBC driver when you call
the isValid(timeout) method. We strongly recommend se�ing up such a property.

Validation comes at a cost, and you should decide what value works best for your application. Here is

5 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

Validation comes at a cost, and you should decide what value works best for your application. Here is
an analysis showcasing the processing time associated with each value:

You may add other HikariCP properties based on your application requirements however, when se�ing
multiple data source properties beware of the syntax and side e�ects.

We also recommend enabling additional logging to verify that your properties where correctly
registered:

Copy code snippet

[Link]=DEBUG

Please refer to the HikariCP documentation for more details.

An example of a DataSourceCon�g de�ning the minimum set of properties that the


DataSource requires to work with the Oracle Database.

Copy code snippet

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

@Configuration
public class DataSourceConfig {

@Bean
public HikariDataSource getDataSource () {
HikariConfig config = new HikariConfig();

6 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

HikariConfig config = new HikariConfig();


[Link]([Link]("JDBC_URL"));
[Link]([Link]("DB_USER"));
[Link]([Link]("DB_PASSWORD"));
[Link](4);
[Link](4);
[Link]("[Link]", "LOC
return new HikariDataSource(config);
}
}

At this stage, you have successfully con�gured your Spring Boot application to work with the Oracle
Database using HikariCP.

The next sections cover the steps for con�guring HikariCP to leverage Oracle Databases’ high
availability capabilities.

With the Oracle Real Application Cluster system (RAC), any Oracle database service is accessible
equally from several server nodes. If a node or a subset of the RAC cluster fails or is taken o�ine for
maintenance, the database is still accessible through the remaining active nodes.

The building blocks for implementing Application High Availability with the Oracle database are:
using a database service, con�guring a URL or a connection string for High Availability, enabling Fast
Application Noti�cation (FAN), implementing draining, and enabling continuous database availability
for Java applications.
You may choose the level of HA that suits your requirements. A detailed explanation of HA protection
levels can be found in Oracle’s “High Availability Overview and Best Practices” under the Application
High Availability Levels chapter.

The following steps allow you to con�gure the Oracle RAC system, the Oracle JDBC driver, and
HikariCP for sustaining planned and unplanned outages. The detailed steps and explanations for the
continuous availability of your applications are covered in Oracle’s “High Availability Overview and Best
Practices” documentation.

Implement a level of high availability that allows applications to immediately react to instance, node, or
database failures, and quickly establish new connections to surviving database instances.

With application HA Level 1, downtime is minimized for unplanned and planned outages.

With Oracle RAC, the Oracle database service may be deployed over several nodes in the cluster.

7 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

With Oracle RAC, the Oracle database service may be deployed over several nodes in the cluster.
Planned outage allows performing maintenance operations on a subset of the service nodes/hosts.
The database admin issues a command that generates a planned down event. As HikariCP is not
instrumented to handle such event type, it will be handled by the Oracle JDBC. The driver will drain i.e.,
transparently and smoothly close all active connections thereby allowing the nodes scheduled for
maintenance, to be shut down without impacting the applications (the remaining active nodes will
absorb the workload).

Create a dedicated service to support HA features as follows. A detailed explanation of how to create a
dedicated service and a connect string can be found in Oracle’s “High Availability Overview and Best
Practices” under the Application High Availability Levels chapter.

Copy code snippet

$ srvctl add service -db mydb -service MYSERVICE -pdb mypdb


-notification TRUE

Con�gure your Java application to use the following connect string.

Copy code snippet

jdbc:oracle:thin:@(DESCRIPTION =
(CONNECT_TIMEOUT= 3)(RETRY_COUNT=4)(RETRY_DELAY=2)
(TRANSPORT_CONNECT_TIMEOUT=3) (ADDRESS_LIST = (LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL = TCP)(HOST=clu_site_scan)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME = my_service)))

As HikariCP has not been instrumented to handle FAN events, the planned maintenance will be
managed by the Oracle JDBC driver. To con�gure the driver to handle FAN events,
add simplefan and ons jar �les to your project’s [Link].

Copy code snippet

<dependencies>
...
<dependency>
<groupId>[Link]</groupId>
<artifactId>ons</artifactId>
<version>${[Link]}</version>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>simplefan</artifactId>

8 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

<artifactId>simplefan</artifactId>
<version>${[Link]}</version>
</dependency>
...
</dependencies>

At this stage, the basic High Availability has been con�gured and furnishes the following bene�ts:

�. FAN event noti�cation of unplanned connection failures. This is especially useful when the failure
may have resulted in an application hang, such as when a database node is failing, and the TCP/IP
sockets are not cleaned up.

�. A connection string that results in connection requests being load-balanced across multiple RAC
nodes using Single Client Access Name (SCAN) with retry on failure.

If your application has been designed to handle planned and unplanned outages via retry logic, then
you don’t need anything else.

To prepare applications for planned maintenance, enable the request boundaries and add the
following connection validation se�ings to your application code.

Please note that the major change in Hikari 6.0.0 is a support for request boundaries and this feature
is disabled by default. Enabling the request boundaries will make draining more e�cient - drain can
occur at both checkout's (i.e., at connection-validation) and checkin's (i.e., at endRequest). It also
enables a complete support for both AC-manual and TAC. Request boundaries should be enabled by
se�ing the following system property:

[Link]("[Link]", "true");

Please be aware that a system property has JVM scope, so all HikariCP pools in that JVM instance will
be a�ected by such a se�ing.

By design, HikariCP validates connections that have been idle for more than 500ms (in the latest
version). If a connection is constantly being checked out and checked in it won’t be validated, and
hence won’t be drained by the Oracle JDBC driver.
Set the following system property either as a JVM system property or programmatically in your
DataSourceCon�g (as shown below) to force connection validation at checkout.

[Link]("[Link]", "-1");

A systematic connection validation on borrow may have a slight performance impact; Oracle
recommends se�ing a lightweight connection validation property

9 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

[Link] to " or " (SOCKET has a small


performance penalty while LOCAL might limit the driver's ability to detect the outage) to mitigate the
impact:

setProperty("[Link]", "SOCKET");

Se�ing the data source class name using the [Link] or the [Link]
�les, throws the following error message: “Caused by: [Link]: both
driverClassName and dataSourceClassName”. We need to set it programmatically using
DataSourceCon�g class as follows (at this point, we recommend to use only
�le for any additional se�ings and not to combine it with �le).

Copy code snippet

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

@Configuration
public class DataSourceConfig {

@Bean
public HikariDataSource getDataSource () {

[Link]("[Link]", "-1");
[Link]("[Link]", "true");
HikariConfig config = new HikariConfig();
[Link]("url",[Link]("JDBC_URL"));
[Link]([Link]("DB_USER"));
[Link]([Link]("DB_PASSWORD"));
[Link]("[Link]"
[Link](4);
[Link](4);
Properties props = new Properties();
[Link]("[Link]", "SOCKET");
[Link]("connectionProperties", props);
return new HikariDataSource(config);
}
}

change the value of con�[Link] for the data source


creation to [Link]:

10 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

Copy code snippet

[Link]("[Link]");

The following command initiates the draining of active sessions.


The "-drain_timeout 60" parameter, allows active sessions to �nish their requests within a
prede�ned timeout (60 sec).

Copy code snippet

srvctl stop instance -db mydb -node node1 -stopoption immediate


–drain_timeout 60 -force -failover

For the planned outage test, we will be using a two-node Oracle RAC environment. During normal
operation, both RAC nodes are up and running and serving the application. Depending on your load-
balancing strategy, the number of sessions might be di�erent or equally distributed across both nodes.
Under load (i.e., database activities), observe that the connections from that instance and
that the instance/node can be shut down.

We will monitor the draining process using the following SQL statement:

Copy code snippet

select systimestamp time, machine, inst_id, count(*) from gv$session where username=

During normal operation, both RAC nodes db1 and db2 (inst_id 1 and inst_id2) are up and running. The
following SQL output demonstrates how sessions for app1 and app2 are being distributed (count *
column). Each application is using a connection pool that is con�gured to hold 4 sessions.

Copy code snippet

SQL>
TIME MACHINE INST_ID COUNT(*)
----------------------------------- --------- ---------- ----------
04-NOV-24 12.33.23.964298 AM +00:00 app1 2 3
04-NOV-24 12.33.23.964298 AM +00:00 app2 1 4
04-NOV-24 12.33.23.964298 AM +00:00 app2 1 1

To begin the planned maintenance test, we �rst stop the database services on node 1 using the
following command:

11 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

following command:

Copy code snippet

srvctl stop instance -db $(srvctl config database) -node db1 -stopoption immediate -

Fast Application Noti�cation (FAN) sends a stop event. The connection pool reacts to FAN and starts
closing connections on node 1. At the same time, new connections are being opened on node 2. The
active session on node 1 is still executing its work. If it �nishes within the drain timeout (10 sec) and
returns the connection to the pool, then the session is closed, and a new one is established on node 2
when requested.

Copy code snippet

SQL>
TIME MACHINE INST_ID COUNT(*)
----------------------------------- --------- ---------- ----------
04-NOV-24 12.33.29.945024 AM +00:00 app1 2 3
04-NOV-24 12.33.29.945024 AM +00:00 app2 2 4
04-NOV-24 12.33.29.945024 AM +00:00 app2 1 1

If the drain timeout completes but the remaining session is still connected to node 1, it will be
disconnected. With Application Continuity in place, the session reconnects to node 2, and the
interrupted work will be replayed transparently to the end user. See the next section for replay
con�guration details.

Copy code snippet

SQL>
TIME MACHINE INST_ID COUNT(*)
----------------------------------- --------- ---------- ----------
04-NOV-24 12.33.31.964371 AM +00:00 app1 2 4
04-NOV-24 12.33.31.964371 AM +00:00 app2 2 4

For planned maintenance, draining is used to allow active sessions to �nish their work (drain) before
the database instance is shut down. However, in unplanned events such as an instance, node, or
database service failures, all sessions connected to the faulty node/instance will be terminated
immediately — there is no time for draining. The Fast Application Noti�cation (FAN) mechanism will
detect those unplanned events and notify the JDBC driver or any connection pool such as UCP that
has been instrumented to receive and process the FAN messages.

12 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

As HikarCPi is not capable of handling FAN events, the Oracle JDBC driver transparently cleans up the
orphan connections and replays in-�ight requests on a surviving database instance (using new
connections); the failures will therefore be transparent to the applications that were using those
connections.

1. Add the following parameters to the database service de�nition:

-failovertype AUTO → enables Transparent Application Continuity (TAC).

-failover_restore AUTO → restores client states automatically

-replay_init_time 600 → speci�es the time in seconds upon which the replay will not be
performed.

Copy code snippet

$ srvctl add service -db mydb -service MYSERVICE -pdb mypdb


-notification TRUE -failover_restore AUTO -failovertype AUTO -replay_init_time 600

2. We recommend se�ing " to " to have a be�er


coverage for unplanned outages.

Copy code snippet

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

@Configuration
public class DataSourceConfig {

@Bean
public HikariDataSource getDataSource () {

[Link]("[Link]", "-1");
[Link]("[Link]", "true");
HikariConfig config = new HikariConfig();
[Link]("url",[Link]("JDBC_URL"));
[Link]([Link]("DB_USER"));
[Link]([Link]("DB_PASSWORD"));
[Link]("[Link]"
[Link](4);
[Link](4);

13 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

[Link](4);
Properties props = new Properties();
[Link]("[Link]", "SOCKET");
[Link]("connectionProperties", props);
return new HikariDataSource(config);
}
}

change the value of con�[Link] for the data source


creation to [Link]:

Copy code snippet

[Link]("[Link]");

Depending on your application functionality and performance needs, you might also consider adding
the following properties to the HikariCP con�guration and/or enable Oracle's Database Resident
Connection Pooling (DRCP):

1. The property → controls the maximum number of


milliseconds an application is willing to wait for a connection from the pool. If pool is exhausted and
this time is reached, then an exception is thrown with a message “connection acquisition timed
out”. Lowest acceptable connection timeout is 250 ms (Oracle's UCP supports much lower
minimum). Default: 30000 (30 seconds).

Note: If the maximum number of connections exhausted from the pool and a new request comes in, it
will behave depending on the connection-timeout. The new request will wait until the connection is
available or it is timed out.

2. The property→ by design HikariCP doesn’t implement a


statement cache as explained by the author. Oracle JDBC thin driver provides an implicit statement
cache that will take care of optimizing how statements and cursors are allocated and freed. To enable it
just set the property " " to a value for example " " which is
usually a good size for the statement cache.

Here are the examples of and including these


properties.

Copy code snippet

# Oracle Database DataSource Configuration


[Link]=${HATEST_JDBC_URL}
[Link]=${HATEST_DB_MAIN_USER}

14 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

[Link]=${HATEST_DB_MAIN_USER}
[Link]=${HATEST_DB_MAIN_PASSWORD}

# HikariCP settings
[Link]-pool-size=4
[Link]-idle=4
[Link]-timeout=250
[Link]
[Link]

Copy code snippet

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];

@Configuration
public class DataSourceConfig {

@Bean
public HikariDataSource getDataSource () {

[Link]("[Link]", "-1");
[Link]("[Link]", "true");
HikariConfig config = new HikariConfig();
[Link]("url",[Link]("JDBC_URL"));
[Link]([Link]("DB_USER"));
[Link]([Link]("DB_PASSWORD"));
[Link]("[Link]"
[Link](4);
[Link](4);
[Link](250);
Properties props = new Properties();
[Link]("[Link]", "SOCKET");
[Link]("[Link]", "10");
[Link]("connectionProperties", props);
return new HikariDataSource(config);
}
}

15 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

3. To enable , you can refer to Oracle’s “Database


Resident Connection Pooling” documentation for detailed con�guration steps. DRCP is a feature of
Oracle Database that allows applications and mid-tier services to e�ciently manage multiple data
requests while optimizing database resource utilization.

Along with enabling DRCP on the server side, you also need to con�gure it on the client side. This
involves se�ing a new connection string and enabling the required properties in the
class.

enable DRCP with SERVER=POOLED in a Network Connect Descriptor string to pass


to JDBC_POOLED_URL

ensure that request boundaries property is enabled:


[Link]("[Link]", "true");

→ this property is used in Spring Boot applications with


HikariCP connection pool to con�gure Oracle Database Resource Pool (DRCP)
→ this property is used to enable or disable DRCP
multiplexing in request APIs when using HikariCP with an Oracle database in a Spring Boot
application

Here are the examples of including these properties:

Copy code snippet

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];

@Configuration
public class DataSourceConfig {

@Bean
public HikariDataSource getDataSource () {

[Link]("[Link]", "-1");
[Link]("[Link]", "true");
HikariConfig config = new HikariConfig();
[Link]("url",[Link]("JDBC_POOLED_URL"));
[Link]([Link]("DB_USER"));
[Link]([Link]("DB_PASSWORD"));

16 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

[Link]([Link]("DB_PASSWORD"));
[Link]("[Link]"
[Link](4);
[Link](4);
[Link](250);
Properties props = new Properties();
[Link]("[Link]", "SOCKET");
[Link]("[Link]", "10");
[Link]("[Link]", "true");
[Link]("[Link]", "DRCP_POOL_NAME");
[Link]("connectionProperties", props);
return new HikariDataSource(config);
}
}

A single ojdbc jar (e.g., [Link], [Link]) for all use cases
(production, debug, metrics). In other words, no more ojdbc8_g.jar or ojdbc11_g.jar for debugging.

Check this blog post — What’s in ‘Oracle DB 23c Free Developer Release’ for Java Developers — to get
more information about the new JDBC Self-Driven Diagnosability in Oracle databse 23ai.

The steps described in this blog post are based on an Oracle RAC system and Oracle JDBC Drivers
v19.21.0.0 and [Link].10. We hope you found this blog post helpful. Thanks for reading!

The Oracle JDBC Developer Guide v19c

High Availability Overview and Best Practices

A Guide to Migrating from HikariCP to Oracle UCP (Universal Connection Pool)

Application Checklist for Continuous Service for Maximum Availability Architecture solutions

Oracle JDBC Driver

Develop Java applications with Oracle Database

Oracle Database 23c Free — Developer Release

Kuassi is Director of Product Management at Oracle, in charge of

17 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

•Java database access, performance , scalability, availability and frameworks


Show more

Irina Granat is a member of MAA group in Oracle Database Development


organization focusing on Microservices and SaaS applications.
Show more

 Previous Post Next Post


Martin Bach | 4 min read Irina Granat | 12 min read

Analyst What is Try Oracle US Sales


About Reports Customer Cloud Free 1.800.633.0738
Service? Tier
Careers Best CRM How can we help?
What is ERP? Oracle
Developers Cloud Subscribe to
Sustainability
Economics What is Oracle Content
Investors Marketing Oracle
Corporate Try Oracle Cloud
Partners Automation? COVID-19
Responsibility Free Tier
Response
Startups What is
Diversity and Events
Procurement? Oracle and
Inclusion
SailGP News
What is Talent
Security
Management?
Practices
What is VM?

18 de 19 03/07/2025, 01:46 p.m.


HikariCP Best Practices for Oracle Database and Spring Boot [Link]

Oracle and
Premier
League
Oracle and
Red Bull
Racing Honda

© 2025 Oracle Privacy / Do Not Sell My Info Preferencias sobre cookies Ad Choices Careers

19 de 19 03/07/2025, 01:46 p.m.

Common questions

Powered by AI

Configuring HikariCP for use in a multi-node Oracle RAC environment involves several steps to maximize the benefits of RAC's failover and load balancing features. First, configure the connect string to utilize Single Client Access Name (SCAN) and enable load balancing. Implement FAN by including the simplefan and ons jar files, which notify client-side software of failover events for better responsiveness. Set up request boundaries to manage connections efficiently during planned maintenances. These configurations enhance HikariCP’s capability to evenly distribute the load across nodes and re-establish connections with the active nodes automatically during node failures, ensuring high availability and robust performance .

To configure HikariCP to leverage Oracle's high availability, several steps need to be followed. First, enable Fast Application Notification (FAN) by adding the 'simplefan' and 'ons' jar files to the project. Then, configure the Oracle Real Application Clusters (RAC) to ensure that the service is accessible across several nodes. This ensures that if a node fails, requests can be handled by the remaining active nodes. Additionally, set request boundaries in HikariCP to make draining efficient and enable connection validation to be lightweight, reducing the performance impact during checkout. The effective configuration ensures minimal service disruption during planned and unplanned downtimes .

When using HikariCP with Oracle Database, important configuration properties include setting the connection validation property to ensure lightweight checks, configuring minimum and maximum pool sizes to optimize resource usage, and tuning the connection timeout to ensure quick recovery from connection pool exhaustion. It's also crucial to manage idle connections to balance performance with resource preservation. Additionally, enabling request boundaries can enhance how HikariCP handles planned and unplanned database downtimes by making checks and draining efficient. Incorporating Oracle-specific properties like 'oracle.jdbc.defaultConnectionValidation' set to 'SOCKET' can further optimize reliability by ensuring timely detection and handling of connection issues .

Connection validation in HikariCP ensures that database connections are alive and capable of handling transactions before being allocated to the application. This validation prevents application errors and resource wastage due to the use of faulty connections. For optimal performance with Oracle Database, it is recommended to set connection validation to a lightweight option like 'SOCKET,' which strikes a balance between performance impact and accuracy in detecting stale connections. Ensuring that connections are validated at sensible intervals helps maintain high availability and reliability without imposing significant overhead on the application .

Migrating from HikariCP to UCP involves several considerations. First, assess the application’s dependency on HikariCP-specific featur facilities, as UCP offers advanced Oracle-specific capabilities like RAC and Data Guard integration, which can affect application architecture. Thoroughly understand UCP's configuration properties, as they differ significantly from HikariCP's. Additionally, migration requires testing and validation to ensure that performance improvements from UCP’s high availability features justify the effort. Careful planning and testing are crucial to handle different error management and connection pooling strategies effectively during the transition .

HikariCP is a lightweight, highly optimized Java connection pool often used in conjunction with Spring Boot for managing database connections. It offers fast performance with efficient use of resources but does not natively support certain high availability features. On the other hand, UCP, provided by Oracle, is a feature-rich connection pool designed to support Oracle's high-availability features out-of-the-box, such as Real Application Cluster (RAC) and Transparent Application Continuity (TAC). It also supports various advanced configurations like Data Guard, Sharding, and Runtime Load Balancing, which are essential for mission-critical applications needing extensive high availability and load management capabilities .

Enabling Request Boundaries in HikariCP offers significant advantages, particularly in scenarios requiring high availability. It allows connection pooling to better manage and drain connections by distinguishing the start and end of a request's lifecycle. This minimizes application disruptions during planned maintenance or failovers as connections can be efficiently closed and reapplied without impacting active transactions, facilitating TAC. However, because Request Boundaries are linked to JVM properties, all connection pools within the same JVM are affected, which could lead to potential overhead due to the increased complexity of connection checks and lifecycle management if not appropriately managed .

Oracle's Universal Connection Pool (UCP) is recommended over HikariCP in scenarios where advanced high availability features are crucial. Situations that would benefit from UCP include environments requiring seamless failover and load balancing across multiple nodes in a cluster, such as when using Oracle Real Application Clusters (RAC), or when detailed resource management and specific Oracle capabilities like Data Guard and Transparent Application Continuity (TAC) are essential. UCP's native support for these Oracle-specific features makes it more suited for mission-critical applications that need robust and fault-tolerant database connectivity .

Oracle Database Resident Connection Pooling (DRCP) complements HikariCP by providing server-side connection pooling, which allows connections to be shared efficiently among multiple client processes. DRCP can significantly reduce the memory footprint and enhance scalability when a large number of lightweight user connections need to be managed. By using DRCP with HikariCP, applications can leverage pooled connections at both the client and server levels, optimizing resource utilization and reducing the response time for establishing connections. Configuring HikariCP to use DRCP involves adjusting the connection string to include 'SERVER=POOLED' and enabling the necessary system properties .

The JDBC BeginRequest and EndRequest APIs facilitate support for Transparent Application Continuity (TAC) in HikariCP by marking the start and end of a request lifecycle. These APIs ensure that connections can be gracefully drained and reused for new work, even during interruptions caused by failovers or server maintenance. This is achieved by automatically replaying transactions that were interrupted, thus ensuring high availability and continuity of applications using the Oracle JDBC driver with HikariCP. By injecting these APIs, HikariCP can transparently manage connection lifecycles similarly to UCP, ensuring minimal service disruption .

You might also like