You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by willie <wm...@gmail.com> on 2011/02/09 17:06:31 UTC

Connection pooling

I created a JCA Connector for Datanucleus. However I noticed the connection
pooling does not return the same connection for a stateful session doing DB
updates, resulting in deadlocks on the databases after a number of calls.
How can one configure connection pooling in OpenEJB to return the same
connection? 
-- 
View this message in context: http://openejb.979440.n4.nabble.com/Connection-pooling-tp3297550p3297550.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Connection pooling

Posted by willie <wm...@gmail.com>.
Thanks, I picked the problem. Another connection was causing the problem.
Thanks again.
-- 
View this message in context: http://openejb.979440.n4.nabble.com/Connection-pooling-tp3297550p3306696.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Connection pooling

Posted by David Blevins <da...@gmail.com>.
On Feb 10, 2011, at 12:02 AM, willie wrote:

> 
> The connector gets its DB connections from openejb. The JDBC connections are
> defined in openejb.xml.
> The connector defination is as follows:
> <connector>
>    <display-name>DataNucleus Connector</display-name>
>    <description></description>
>    <vendor-name>DataNucleus Team</vendor-name>
>    <spec-version>1.0</spec-version>
>    <eis-type>JDO Adaptor</eis-type>
>    <version>1.0</version>
>    <resourceadapter>
> 
> <managedconnectionfactory-class>org.datanucleus.jdo.connector.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
> 
> <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
> 
> <connectionfactory-impl-class>org.datanucleus.jdo.connector.PersistenceManagerFactoryImpl</connectionfactory-impl-class>
> 
> <connection-interface>javax.resource.cci.Connection</connection-interface>
> 
> <connection-impl-class>org.datanucleus.jdo.connector.PersistenceManagerImpl</connection-impl-class>
>        <transaction-support>LocalTransaction</transaction-support>
>        <config-property>
>          <config-property-name>ConnectionFactoryName</config-property-name>
>          <config-property-type>java.lang.String</config-property-type>
>          <config-property-value>jdbc/ds</config-property-value>
>        </config-property>
>        <authentication-mechanism>
> 
> <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
> 
> <credential-interface>javax.resource.security.PasswordCredential</credential-interface>
>        </authentication-mechanism>
>        <reauthentication-support>false</reauthentication-support>
>    </resourceadapter>
> </connector>
> 
> The jdbc connection "jdbc/ds", above is provided by openejb through JDNI. 

Hmm, that's definitely the right approach.  Though I'm not sure the impact 'LocalTransaction' has on the connector.  In JPA that means to use the non-jta-data-source (JtaManaged=false in openejb terms) which won't be shared by everyone in the transaction.

Can you post the config for the jdbc/ds resource?  Best way to do that if running a standalone server is the 'openejb properties' command which will cut passwords out automatically.  If using an embedded container you can use the following system property:

   log4j.category.OpenEJB.startup.service=debug


-David


Re: Connection pooling

Posted by willie <wm...@gmail.com>.
The connector gets its DB connections from openejb. The JDBC connections are
defined in openejb.xml.
The connector defination is as follows:
<connector>
    <display-name>DataNucleus Connector</display-name>
    <description></description>
    <vendor-name>DataNucleus Team</vendor-name>
    <spec-version>1.0</spec-version>
    <eis-type>JDO Adaptor</eis-type>
    <version>1.0</version>
    <resourceadapter>
       
<managedconnectionfactory-class>org.datanucleus.jdo.connector.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
       
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
       
<connectionfactory-impl-class>org.datanucleus.jdo.connector.PersistenceManagerFactoryImpl</connectionfactory-impl-class>
       
<connection-interface>javax.resource.cci.Connection</connection-interface>
       
<connection-impl-class>org.datanucleus.jdo.connector.PersistenceManagerImpl</connection-impl-class>
        <transaction-support>LocalTransaction</transaction-support>
        <config-property>
          <config-property-name>ConnectionFactoryName</config-property-name>
          <config-property-type>java.lang.String</config-property-type>
          <config-property-value>jdbc/ds</config-property-value>
        </config-property>
        <authentication-mechanism>
         
<authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
         
<credential-interface>javax.resource.security.PasswordCredential</credential-interface>
        </authentication-mechanism>
        <reauthentication-support>false</reauthentication-support>
    </resourceadapter>
</connector>

The jdbc connection "jdbc/ds", above is provided by openejb through JDNI. 
-- 
View this message in context: http://openejb.979440.n4.nabble.com/Connection-pooling-tp3297550p3298708.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Connection pooling

Posted by David Blevins <da...@gmail.com>.
On Feb 9, 2011, at 8:06 AM, willie wrote:

> 
> I created a JCA Connector for Datanucleus. However I noticed the connection
> pooling does not return the same connection for a stateful session doing DB
> updates, resulting in deadlocks on the databases after a number of calls.
> How can one configure connection pooling in OpenEJB to return the same
> connection? 

Sounds like something else might be going on as pooling/sharing is enabled by default and works out of the box.

If the 'JtaManaged' property of the data source's <Resource> is set to 'false' then that will shut off sharing.  Also if someone creates their own connection, that would cause problems too.

How does the Connector get connections?

-David