You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Detlef Burt <th...@gmx.net> on 2009/04/23 11:09:56 UTC

Problem with Connection Pooling - only one connection gets used

Hi List,

Before I start, here's what we currently use:
Cayenne 2.0.4
MSSQL Server 2005 with jTDS Driver

In our application we define the following connection pool:
cayenne.dbcp.driverClassName=net.sourceforge.jtds.jdbc.Driver
cayenne.dbcp.url=jdbc:jtds:sqlserver://darkside:1433/mdb
cayenne.dbcp.username=dbuser
cayenne.dbcp.password=dbpassword
cayenne.dbcp.maxActive=10
cayenne.dbcp.minIdle=3
cayenne.dbcp.maxIdle=10
cayenne.dbcp.maxWait=10000

When starting the application everything works fine, we can see 3 
connections to the MSSQL Server.
The Problem is, only one of these connections is used. Because we used 
external transactions, we disabled them to let cayenne do the 
committing, but that didn't help either. The only result was, that data 
wasn't written to the database.

We also tried recreating the DataContext every time we access the 
database, nothing helped.

Neither the DBCPDataSourceFactor nor the Cayenne DriverDataSourceFactory 
return an unused connection.

So now my question is:
How does Cayenne handle the connection pool? Is there a way to always 
get an unused connection? Or at least determine why cayenne is always 
using the same connection?

Thanks,
Detlef

Re: Problem with Connection Pooling - only one connection gets used

Posted by Andrus Adamchik <an...@objectstyle.org>.
Very strange... Cayenne works with the DataSource, so whatever  
connection DataSource gives it, it will use it. So could you elaborate  
what you mean by "only one of these connections is used"? Does that  
mean that for a single slow operations, other threads can't get  
connections from the pool?

Andrus


On Apr 23, 2009, at 12:09 PM, Detlef Burt wrote:

> Hi List,
>
> Before I start, here's what we currently use:
> Cayenne 2.0.4
> MSSQL Server 2005 with jTDS Driver
>
> In our application we define the following connection pool:
> cayenne.dbcp.driverClassName=net.sourceforge.jtds.jdbc.Driver
> cayenne.dbcp.url=jdbc:jtds:sqlserver://darkside:1433/mdb
> cayenne.dbcp.username=dbuser
> cayenne.dbcp.password=dbpassword
> cayenne.dbcp.maxActive=10
> cayenne.dbcp.minIdle=3
> cayenne.dbcp.maxIdle=10
> cayenne.dbcp.maxWait=10000
>
> When starting the application everything works fine, we can see 3  
> connections to the MSSQL Server.
> The Problem is, only one of these connections is used. Because we  
> used external transactions, we disabled them to let cayenne do the  
> committing, but that didn't help either. The only result was, that  
> data wasn't written to the database.
>
> We also tried recreating the DataContext every time we access the  
> database, nothing helped.
>
> Neither the DBCPDataSourceFactor nor the Cayenne  
> DriverDataSourceFactory return an unused connection.
>
> So now my question is:
> How does Cayenne handle the connection pool? Is there a way to  
> always get an unused connection? Or at least determine why cayenne  
> is always using the same connection?
>
> Thanks,
> Detlef
>