3.15.2.1. Apache Commons DBCP Configuration Options
The JDBC DataSource configuration options that we will need to modify in order to use Apache Commons DBCP for connection pooling are:
connectionDriverName="org.apache.commons.dbcp.BasicDataSource"
connectionProperties="DriverClassName=<prior connectionDriverName>, ..."
Additional Commons DBCP arguments can be provided in the connectionProperties value, such as:
MaxTotal=10,MaxIdle=5,MinIdle=2,MaxWait=60000
Please visit the Commons DBCP website for the entire list of configuration options and explanations.
For example, to use Commons DBCP with an Apache Derby database server, we would need to provide the following settings, as either settings in the persistence.xml or as system environment overrides:
<property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/>
<property name="openjpa.ConnectionProperties" value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver, Url=jdbc:derby://localhost:1527/openjpa, Username=uid, Password=pwd"/>
Notice that we supplied Username and Password settings, which are required by Commons DBCP for connecting to a database over the network, but can be dummy values if database security is not enabled.