blob: c2f496cd39e9a48599698b9641e06dd6c98a4d9e [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.&nbsp; Apache Commons DBCP</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><base href="display"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA 2.1 User's Guide"><link rel="up" href="ref_guide_integration.html" title="Chapter&nbsp;14.&nbsp; Third Party Integration"><link rel="prev" href="ref_guide_integration.html" title="Chapter&nbsp;14.&nbsp; Third Party Integration"><link rel="next" href="ref_guide_optimization.html" title="Chapter&nbsp;15.&nbsp; Optimization Guidelines"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.&nbsp;
Apache Commons DBCP
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_integration.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;14.&nbsp;
Third Party Integration
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_optimization.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_integration_dbcp"></a>2.&nbsp;
Apache Commons DBCP
</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ref_guide_integration_dbcp.html#ref_guide_integration_dbcp_conf">2.1.
Apache Commons DBCP Configuration Options
</a></span></dt></dl></div><a class="indexterm" name="d0e36003"></a><p>
OpenJPA does not provide its own JDBC connection pooling, as this should already be supplied to applications running in a Java EE application server in container managed mode. For Java SE or applications running in application managed mode, the OpenJPA aggregate <code class="literal">openjpa-all.jar</code> artifact and the binary assembly contains copies of <a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://commons.apache.org/dbcp/" target="_top">Apache Commons DBCP</a>, which provides a robust connection pooling implementation.
</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="ref_guide_integration_dbcp_conf"></a>2.1.&nbsp;
Apache Commons DBCP Configuration Options
</h3></div></div></div><a class="indexterm" name="d0e36017"></a><p>
The <a href="ref_guide_dbsetup_thirdparty.html" title="2.&nbsp; Using a Third-Party DataSource">JDBC DataSource configuration options</a> that we will need to modify in order to use Apache Commons DBCP for connection pooling are:
</p><pre class="programlisting">
connectionDriverName="org.apache.commons.dbcp.BasicDataSource"
connectionProperties="DriverClassName=&lt;prior connectionDriverName&gt;, ..."
</pre><p>
Additional Commons DBCP arguments can be provided in the connectionProperties value, such as:
</p><pre class="programlisting">
MaxActive=10,MaxIdle=5,MinIdle=2,MaxWait=60000
</pre><p>
Please visit the Commons DBCP website for the entire list of <a xmlns:xlink="http://www.w3.org/1999/xlink" href="http://commons.apache.org/dbcp/configuration.html" target="_top">configuration options</a> and explanations.
</p><div class="example"><a name="ref_guide_integration_dbcp_derby"></a><p class="title"><b>Example&nbsp;14.11.&nbsp;
Using Commons DBCP with Apache Derby
</b></p><div class="example-contents">
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:
<pre class="programlisting">
&lt;property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/&gt;
&lt;property name="openjpa.ConnectionProperties" value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver, Url=jdbc:derby://localhost:1527/openjpa, Username=uid, Password=pwd"/&gt;
</pre>
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.
</div></div><br class="example-break"></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_integration.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide_integration.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_optimization.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;14.&nbsp;
Third Party Integration
&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;15.&nbsp;
Optimization Guidelines
</td></tr></table></div></body></html>