How do I create a BasicDataSource object?

This example demonstrate how to use the BasicDataSource class of Apache Commons DBCP to create a basic requirements for database connection. The configuration of the data source can be defined using some properties method provided by this class. The basic properties is the driver classname, connection url, username and password.

After the datasource ready we can obtain a connection by calling the getConnection method of the datasource. This method might throw an SQLException when errors occurs.

How do I create a database connection pool?

This example show you how to create a connection pool implementation using the Apache Commons DBCP library.