Implementing connection pools
We should now understand what connection pools are and the associated advantages and challenges. Let’s extend our knowledge by implementing connection pools using Java. In this section, we will look at connection pool libraries, set up a connection pool, integrate our connection pool with application logic, and explore how to monitor our connection pools.
Connection pool libraries
Once we decide to use connection pools in an application, we need to select an appropriate connection pool library. There are several connection pool libraries available to us for Java, and which one we select is based on our application’s requirements. Let’s look at three popular connection pool libraries.
Apache Commons Database Connection Pooling (DBCP) is a mature library that is considered stable and has wide applicability. As the name suggests, this is an open-source library from Apache. While this is a proven library, it is less efficient...