3.5.1.1. Optional Connection Pooling
Starting with OpenJPA 2.1, a new org.apache.openjpa.jdbc.schema.AutoDriverDataSource is provided as the default, which will automatically select between the old SimpleDriverDataSource and a new DBCPDriverDataSource implementation based on if Apache Commons DBCP2 has been provided on the classpath and OpenJPA is not running in a container managed mode or with managed transactions.
Note, that only the openjpa-all.jar includes Commons DBCP2, so you will need to include the commons-dbcp2.jar from the OpenJPA binary distribution if you are using the normal openjpa.jar.
To disable the automatic usage of Apache Commons DBCP when it is discovered on the classpath, set openjpa.jdbc.DriverDataSource=simple, which will revert OpenJPA to the prior behavior of using org.apache.openjpa.jdbc.schema.SimpleDriverDataSource
To force usage of Apache Commons DBCP2, which will cause a fatal exception to be thrown if it cannot be loaded from the classpath, set openjpa.jdbc.DriverDataSource=dbcp, which will cause OpenJPA to use org.apache.commons.dbcp2.BasicDataSource