Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quick links: redhat.com, Customer Portal, Red Hat's developer site, Red Hat's partner site.

  • You are here

    Red Hat

    Learn about our open source products, services, and company.

  • You are here

    Red Hat Customer Portal

    Get product support and knowledge from the open source experts.

  • You are here

    Red Hat Developer

    Read developer tutorials and download Red Hat software for cloud application development.

  • You are here

    Red Hat Partner Connect

    Get training, subscriptions, certifications, and more for partners to build, sell, and support customer solutions.

Products & tools

  • Ansible.com

    Learn about and try our IT automation product.
  • Red Hat Ecosystem Catalog

    Find hardware, software, and cloud providers―and download container images―certified to perform with Red Hat technologies.

Try, buy, & sell

  • Red Hat Hybrid Cloud Console

    Access technical how-tos, tutorials, and learning paths focused on Red Hat’s hybrid cloud managed services.
  • Red Hat Store

    Buy select Red Hat products and services online.
  • Red Hat Marketplace

    Try, buy, sell, and manage certified enterprise software for container-based environments.

Events

  • Red Hat Summit and AnsibleFest

    Register for and learn about our annual open source IT industry event.

Use Oracle's Universal Connection Pool with Red Hat JBoss Enterprise Application Platform 7.3 and Oracle RAC

December 7, 2020
Syed M Shaaf Pablo Silberkasten
Related topics:
DevOpsJavaSecurity
Related products:
Red Hat JBoss Enterprise Application Platform

Share:

Share on twitter Share on facebook Share on linkedin Share with email
  • What is connection pooling?
  • Integrating Universal Connection Pool with an Oracle RAC database
  • Configuring Oracle UCP with JBoss EAP
  • Using Oracle UCP in a JBoss EAP deployment
  • Conclusion

Data is a critical business application component, but ensuring consistent, reliable data access can be challenging. Adding distributed services and high availability to your application requirements makes data access even more complicated. You can now use Oracle's Universal Connection Pool (UCP) together with Oracle Real Application Clusters (RAC) and Red Hat JBoss Enterprise Application Platform (JBoss EAP) 7.3. This article introduces connection pooling with Oracle Universal Connection Pool and demonstrates how to integrate UCP with an Oracle RAC database in a JBoss EAP 7.3 deployment.

What is connection pooling?

What is connection pooling?

A connection pool is a group of connection objects that represent physical database connections. At runtime, an application requests a connection from the pool. When the application is finished with the connection, it releases it back to the pool.

Opening a physical connection to a database involves establishing a TCP/IP connection, negotiating session parameters (from the protocol), and authenticating the user. User authentication can require considerable processing for heavy cryptographic key generation. Worse, each of these steps requires a remote procedure call (RPC), which entails a network round-trip to the database with the implied network latency.

Achieving maximum application uptime without interruptions requires outage detection, transparent planned maintenance, and balancing the workload. All of these factors critically influence application availability and performance. Connection pooling is an effective means of handling these concerns. Just as critically, connection pooling lets us re-use connections rather than starting a new one each time a request is made.

Connection pooling minimizes the use of resources in both the client and the database. The client only needs to access a pool of active connections, which is shared by a larger number of clients. In the database, each active connection allocates a set of resources—both in memory and in the CPU—that can be minimized by using a pool in the client.

When using Oracle Universal Connection Pool (UCP), a Java developer opens and closes connections only at the logical level. Connections are kept active in the pool and borrowed and returned to the pool as needed.

In the next sections, we will demonstrate a couple of ways to integrate UCP with an Oracle RAC database in a JBoss EAP deployment.

Integrating Universal Connection Pool with an Oracle RAC database

Integrating Universal Connection Pool with an Oracle RAC database

Beyond the intrinsic benefits of connection pooling, developers implementing UCP with an Oracle RAC database can leverage additional features in the connection pool. These features—addressing high availability, scalability, and performance—are as follows:

  • Runtime connection load balancing allows UCP to acquire connections based on the load of the nodes in the cluster.
  • Fast connection failover supports unplanned outages and rapidly replaces dead connections in the pool. Failover also supports planned outages and helps ensure that connections are not interrupted until their work is done.
  • Transaction affinity allows an ongoing transaction to stick to a specific node in the cluster, thus improving performance.
  • Built-in support for database-resident connection pooling and application continuity provide seamless integration with server-side pooling and mask outages to support in-flight transaction recovery.
  • Explicit request boundaries begin when a connection is borrowed from UCP and ends when the connection is returned to the connection pool. The JDBC driver provides the explicit request boundary declaration APIs beginRequest and endRequest.

Oracle UCP is automatically configured to listen for Oracle notification service events in a RAC instance. Listener events include:

  • Service up/down
  • Node up/down
  • Load balancing and affinity advice
Configuring Oracle UCP with JBoss EAP

Configuring Oracle UCP with JBoss EAP

There are two possible approaches to configuring Oracle Universal Connection Pool with JBoss EAP. We will consider them both.

Option 1: Configure UCP with a web application descriptor (web.xml)

This approach lets you configure the connection pool using the standard web application descriptor of a web.xml file and <context-param> name-value pairs. Each name uses the prefix "ucp." to identify as a UCP argument. The following web.xml sets the jndiName, URL, connectionFactoryClassName, and dataSourceName, as well as identifying the user of a connection in the pool:

<web-app>

...

<context-param>

<param-name>ucp.jndiName</param-name>

<param-value>java:/datasources/mypool_usingwl</param-value>

</context-param>

<context-param>

<param-name>ucp.URL</param-name>

<param-value>jdbc:oracle:thin:@myhost:5521/myservice</param-value>

</context-param>

<context-param>

<param-name>ucp.connectionFactoryClassName</param-name>

<param-value>oracle.jdbc.replay.OracleDataSourceImpl</param-value>

</context-param>

<context-param>

<param-name>ucp.dataSourceName</param-name>

<param-value>myDataSource</param-value>

</context-param>

<context-param>

<param-name>ucp.user</param-name>

<param-value>scott</param-value>

</context-param>

<listener>
    <listener-class>oracle.ucp.jdbc.UCPServletContextListener</listener-class>
</listener>

</web-app>

Note that the name of the attribute in <param-name> should be formed with the ucp. prefix and the name of the setter without the set prefix. As an example, ucp.initialPoolSize maps to setInitialPoolSize(int).

Note: For a complete list of Universal Connection Pool configuration values, please visit the Oracle UCP documentation.

Option 2: Configure UCP with an XML configuration file

To use this configuration option, you must first set the JVM system property to oracle.ucp.jdbc.xmlConfigFile. In the web.xml, ensure that the ucp.dataSourceNameFromXMLConfig parameter matches a value for the data-source-attribute from /ucp-properties/connection-pool/data-source/data-source-name.

For this web.xml:

-Doracle.ucp.jdbc.xmlConfigFile=file:/Users/scott/conf/ucp_config.xml

Pass the following values:

<web-app>

...

<context-param>

<param-name>ucp.dataSourceNameFromXMLConfig</param-name>

<param-value>myDataSourceInXml</param-value>

</context-param>

Then /Users/scott/conf/ucp_config.xml

<ucp-properties>

    <connection-pool

    connection-factory-class-name="oracle.jdbc.replay.OracleDataSourceImpl"

    connection-pool-name="pool1"

    initial-pool-size="10"

    max-connections-per-service="15"

    max-pool-size="30"

    min-pool-size="2"

    password="*****"

    url="jdbc:oracle:thin:@myhost:5521/myservice”

    user="scott">

    <connection-property name="autoCommit" value="false"></connection-property>

    <connection-property name="oracle.net.OUTBOUND_CONNECT_TIMEOUT" value="2000">

    </connection-property>

    <data-source data-source-name="myDataSourceInXml" description="pdb1" service="ac">

    </data-source>

    </connection-pool>

</ucp-properties>
Using Oracle UCP in a JBoss EAP deployment

Using Oracle UCP in a JBoss EAP deployment

UCP creates a connection pool when the application server is started or deployed. When this event occurs, the object reads the configuration or description file and create a UCP data source with the configured values. It then uses the Java Naming and Directory Interface (JNDI) to bind the data source to the configured address. It also binds the data source to an application-scoped object, which is injected using Context and Dependency Injection (CDI). Contained objects can use the JNDI address and application-scoped object to retrieve the data source and its connections. The application-scoped object and the JNDI-retrieved data source are in the same pool, so this mechanism creates no duplication.

There are two possible approaches to using UCP in a JBoss EAP deployment.

Option 1: Using Context and Dependency Injection (CDI)

First, here is an example of using CDI for this purpose:

@Inject

@UCPResource

private DataSource ds;

In this case, the data source is ready to use. No additional code is needed.

Option 2: Using the Java Naming and Directory Interface (JNDI)

This second option is to use the Java Naming and Directory Interface. To use JNDI, you will need to perform the additional step of retrieving the pool and associating it to the data source:

public class OracleUcp extends HttpServlet { // sample usage in a servlet

  private DataSource ds = null;

  // Retrieve Datasource reference using JNDI

  @Override

  public void init() throws ServletException { // association must occur after init

    Context initContext;

    try {

      initContext = new InitialContext();

      ds = (DataSource) initContext.lookup("java:/datasources/mypool_usingwl");
Conclusion

Conclusion

We hope the discussion and examples we have shared in this article have helped you understand how to use Oracle UCP and Oracle RAC in a JBoss EAP deployment. Using these technologies together is a great way to develop resilient, highly available applications. We recommend the following additional resources for exploring more about JBoss EAP:

  • * The feature described in this article is available for Oracle versions 21.3.0.0 and above.
  • Visit Red Hat Developer's JBoss EAP homepage for an overview of JBoss Enterprise Application Platform.
  • See New Packaging capabilities with Red Hat JBoss EAP (James Falkner, April 2020) to learn about the new packaging capabilities in JBoss EAP 7.3.
  • Developing Microprofile apps with Red Hat JBoss EAP (Emmanuel Hugonnet, July 2020) offers more application development examples with JBoss EAP.
Last updated: August 14, 2023

Related Posts

  • JBoss EAP 7.3 brings new packaging capabilities

  • Load balancing Red Hat JBoss Enterprise Application Platform subclusters with mod_cluster

Recent Posts

  • Alternatives to creating bootc images from scratch

  • How to update OpenStack Services on OpenShift

  • How to integrate vLLM inference into your macOS and iOS apps

  • How Insights events enhance system life cycle management

  • Meet the Red Hat Node.js team at PowerUP 2025

What’s up next?

Read Open Source Data Pipelines for Intelligent Applications to gain insight into how Kubernetes provides a platform for building data platforms that increase an organization’s data agility. You'll also learn how to design scalable data storage and artificial intelligence applications for private, public, and multicloud infrastructures.

Get the e-book
Red Hat Developers logo LinkedIn YouTube Twitter Facebook

Products

  • Red Hat Enterprise Linux
  • Red Hat OpenShift
  • Red Hat Ansible Automation Platform

Build

  • Developer Sandbox
  • Developer Tools
  • Interactive Tutorials
  • API Catalog

Quicklinks

  • Learning Resources
  • E-books
  • Cheat Sheets
  • Blog
  • Events
  • Newsletter

Communicate

  • About us
  • Contact sales
  • Find a partner
  • Report a website issue
  • Site Status Dashboard
  • Report a security problem

RED HAT DEVELOPER

Build here. Go anywhere.

We serve the builders. The problem solvers who create careers with code.

Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

Sign me up

Red Hat legal and privacy links

  • About Red Hat
  • Jobs
  • Events
  • Locations
  • Contact Red Hat
  • Red Hat Blog
  • Inclusion at Red Hat
  • Cool Stuff Store
  • Red Hat Summit

Red Hat legal and privacy links

  • Privacy statement
  • Terms of use
  • All policies and guidelines
  • Digital accessibility

Report a website issue