Home » Core Java » apache » commons » dbcp

dbcp

DBCP Connection Pooling Example

We will be writing a series of examples demonstrating how to configure Connection Pooling in your Java Application using different libraries like DBCP, C3P0, HikariCP etc. In this example, we shall demonstrate how to achieve connection pooling using the Apache DBCP library. 1. Why use Connection Pooling? To present dynamic data to the users, an application typically connects to a ...

Read More »

org.apache.commons.dbcp2.PoolingConnection Example

In this example, we shall show you how to use PoolingConnection of Apache commons dbcp2 library. DBCP is a part of Apache common components and intended for database connection pooling. PoolingConnection is a delegating connection that pools java.sql.PreparedStatement. The prepared statement will be either created or returned from the pool by PoolingConnection as shown in example below. Clients of this class needs ...

Read More »

org.apache.commons.dbcp.BasicDataSource Example

In this example, we shall show you how to use BasicDataSource of Apache commons dbcp library. DBCP is a part of apache common components and intended for database connection pooling. BasicDataSource is a basic implementation of javax.sql.DataSource Using BasicDataSource, one can easily connect to a Relational Database as we will show in following example. For this example, we will be using ...

Read More »

Create a simple BasicDataSource object

With this example we are going to demonstrate how to create a simple org.apache.commons.dbcp.BasicDataSource object, that is the basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. In short, to create a simple BasicDataSource object you should: Create a BasicDataSource object and configure the database. Use setDriverClassName(String driverClassName) method to set the jdbc driver class name. Use setUrl(String url) method ...

Read More »