What is a connection pool?

Asked 14-Nov-2017
Viewed 493 times

1 Answer


0

“Connection Pool” 

Connection Pool is the cache of a database, which maintain the connection when we reused future requests. Generally, it is used for increasing the performance of executing commands on a database. In connection pooling, when the connection is created, it is placed in the pool and reused again before establishing new connections. 

"Connection Pool Architecture"
What is a connection pool?


JDBC Connection Pooling Scope:

import java.sql.*;
public class JDBCServlet extends HttpServlet { 
    private Connection connection; 
    public void init(ServletConfig c) throws ServletException { 
       ……………..
     …………….. // write some code for Open the connection
     ………………….
    }
    public void destroy() {
   ………………………..
    …………………. //write some code for Close the connection
    }
    public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException {
    ……………..
     ………….. //Use the connection here
      Statement stmt = connection.createStatement();
      …………………..
…………………. // perform JDBC Work
…………………
  }
}