Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

    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?

    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

    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

    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

    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

    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

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    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

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.