Connection pool and long connection

Creating a connection to the database and releasing it every time it is used makes frequent database visits really slow since creating a connection has a long process in TCP handshaking etc.

Keeping the connection alive until it gets closed by the database makes data operation faster.

I looked into how to write code for a connection pool in JMVC.

The pool is also a store that keeps live connections, Compared to every time closing the connection after use, the connection pool disposes of all managed connections and they can be closed manually, but they don't get closed after use, they are saved in the live connection store so whenever database connection is required, a live connection is fetched from the store and no cost for creating a new connection again, after some time, one connection is shutdown automatically, the pool checks whether the live connection count has reached to configured max, or else it keeps maintaining the pool by creating a new connection or fetching one existing connection, and in this way, the connections get reused.