Javarevisited

A humble place to learn Java and Programming better.

Follow publication

Why do we need a Database Connection Pool? -every programmer must know

Dineshchandgr - A Top writer in Technology
Javarevisited
Published in
10 min readDec 17, 2022

Hello everyone. In this article, we are going to look at Database connections and their life cycle. Then we will look at the Connection Pool, its internals, and why we need to use it. Then we will look at the design patterns on where to place the connection pool. We will then look at the performance issues that can arise from the Database connection pool and conclude the article by looking at the common connection pool frameworks used in Java. Let's get started.

What is a Database Connection?

Any software application needs to store the data in a database and for the application to interact with a database server, we need a Database Connection. The Database connection is nothing but a way for the application software to interact with the database server software and we use the connection to send commands (SQL) to the database and obtain the response from the database in the form of a Result Set.

Image Source: https://softcover.s3.amazonaws.com/14738/python_book/images/connect_database3.jpg

The database application usually runs in a dedicated server called a database server which is different from the application servers. The database application runs in a specific port in the database server on which the application server can send commands and receive the data. Eg: MySQL database application runs in a default port called 3306 in the database server machine. This is exactly the same way as the backend application running in port 8080.

Whenever a client like a browser or mobile requests data from the backend application, the backend application needs to talk to the database to retrieve the data and respond to the client.

If a backend application wants to connect to the database server application, it needs to make a call over TCP-IP protocol along with the database server IP and Port info and the credentials to connect. The process of the application server connecting to the database server to obtain data is achieved through a mechanism called Database Connection.

To build a Database connection, we need to provide the information like server URL that contains the host, port and the name of

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

Dineshchandgr - A Top writer in Technology
Dineshchandgr - A Top writer in Technology

Written by Dineshchandgr - A Top writer in Technology

Principal Software Engineer and Technical Lead focussed on Backend Engineering who likes to upgrade the tech skills and share knowledge to the community

Responses (7)

Write a response

What could be said in addtion to everything already mentioned, is how to configure correctly a DB connection pool, or maybe it could be another article?
We would like to configure a database connection pool with the following goals in mind:
the DB…

--

i think thanos.chat is awesome

--

really well written article, thx

--