The JDBC Connection Pool tutorial discusses about the Connection Pooling in Java.The JDBC Connection Pool tutorial discusses about the Connection Pooling in Java.
In this section we will learn about JDBC Connection Pool and see how to use Apache DBCP for creating the database connection pool. We will also see some examples of executing SQL statements against database. Your application will give you improved performance if you use the JDBC Connection pooling.
What is JDBC Connection Pool?
The database connection is expensive object and it requires a lot of effort to connect to the database and get a connection object. You can then use the same connection object to execute a number of SQL statements. In a high traffic website or web application, getting a new connection from the database for each user request is a huge work and it makes the website slow. There is another mechanism to store a number of connection in a pool and then get the connection from the pool to process user request. One the request is processed you can return the connection to the pool. Thus the Connection Pooling is the mechanism of storing a number of live database connection in resource pool.
You can make your own code for JDBC connection pooling but instead of writing the code from scratch you can use Apache DBCP. Read Apache DBCP Tutorial for more information on using it for making database connection and executing the SQL statements
Benefits of JDBC Connection Pooling
Here are the benefits of JDBC Connection Pooling:
Tutorial of JDBC Connection pooling
Read the following tutorials on JDBC Connection pooling: