openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Prud'hommeaux <mprud...@apache.org>
Subject Re: Connection pooling trouble
Date Fri, 16 Mar 2007 00:22:59 GMT
Craig-

We don't have any built-in connection pool in OpenJPA, and the  
mechanism for using a 3rd party connection pool is woefully  
underdocumented. If you want to use pooling, you can use Apache DBCP.  
You can configure it using the following properties:

             <property name="openjpa.ConnectionDriverName"  
value="org.apache.commons.dbcp.BasicDataSource"/>
             <property name="openjpa.ConnectionURL"  
value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:der 
by://localhost:1527/ 
pbdb;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/>


Alternatively, or in addition, you can also change how the OpenJPA  
broker holds on to connections. By default, it will grab a connection  
whenever it is needed, and then close it as quickly as possible. This  
makes for efficient use of connections, but when there is no  
connection pool involved, it can be cripplingly slow. It can be  
changed using the "ConnectionRetainMode" property, which is described  
at:

    http://incubator.apache.org/openjpa/docs/latest/manual/ 
manual.html#ref_guide_dbsetup_retain





On Mar 15, 2007, at 4:59 PM, Craig L Russell wrote:

> Hi,
>
> Running 0.9.7 from March 7 (I think; someone else configured this).
>
> Running very short transactions (createEM, begin, find one  
> instance, commit, close EM) I observe that connections are  
> constantly being acquired and then closed (hundreds of times per  
> second). Did I misconfigure the pool somehow?
>
> These settings are in the persistence.xml,
>          
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ 
> provider>
> ...
>             <property name="openjpa.ConnectionDriverName"  
> value="org.apache.derby.jdbc.ClientDriver"/>
>             <property name="openjpa.ConnectionURL"  
> value="jdbc:derby://localhost:1527/pbdb;create=true;"/>
>             <property name="openjpa.ConnectionUserName" value="ejb3"/>
>             <property name="openjpa.ConnectionPassword" value="ejb3"/>
>
>             <property name="openjpa.ConnectionRetainMode"  
> value="always"/>
>             <property name="openjpa.ConnectionFactoryProperties"  
> value="MaxActive=200,MaxIdle=200,MaxCachedStatements=250"/>
>
> Thanks,
>
> Craig
>
> Craig Russell
> DB PMC, OpenJPA PPMC
> clr@apache.org http://db.apache.org/jdo
>
>


Mime
View raw message