You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stanimir Komitov <st...@devbg.piranko.com> on 2008/07/28 17:23:07 UTC

Problem with maxActive connections

Hi,

Why every time when I call HibernateDaoSupport
Session.().createSQLQuery(...)... and the SharedPoolDataSource makes new
one active connection, and never close it, then my maxActive
connections expired and throws the exception 'Timeout waiting for idle
object'?

My configuration parameters are those:

driver=org.postgresql.Driver
url=jdbc:postgresql://xxx.xxx.xxx.xxx/xxx
user=xxxxxxx
password=xxxxxx
maxActive=10
maxIdle=8
maxWait=2000
testOnBorrow=true
validationQuery=select 1
timeBetweenEvictionRunsMillis=300000

but when I`m using HibernateTemplate in the same HibernateDaoSupport the
connections are managed fine and the maxActive connections did not expired!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Problem with maxActive connections

Posted by James Carman <ja...@carmanconsulting.com>.
It looks like this is turning into more of a Spring question than a
DBCP question.  Have you tried asking on their forum?

On Mon, Jul 28, 2008 at 11:40 AM, Stanimir Komitov
<st...@devbg.piranko.com> wrote:
> This is my transaction management xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:tx="http://www.springframework.org/schema/tx"
>        xmlns:aop="http://www.springframework.org/schema/aop"
>        xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
>        <bean id="txManager"
>                class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>                <property name="sessionFactory" ref="testSessionFactory"/>
>        </bean>
>        <tx:advice id="txAdvice" transaction-manager="txManager">
>                <tx:attributes>
>                        <tx:method name="save*" propagation="REQUIRED"
>                                read-only="false" />
>                        <tx:method name="update*" propagation="REQUIRED"
>                                read-only="false" />
>                        <tx:method name="delete*" propagation="REQUIRED"
>                                read-only="false" />
>                        <tx:method name="load*" propagation="REQUIRED"
>                                read-only="true" />
>                </tx:attributes>
>        </tx:advice>
>
>        <aop:config>
>                <aop:pointcut id="testDaoOperation"
>                        expression="execution(* org.xxx.xxx.daos.TestDAO.*(..))" />
>                <aop:advisor advice-ref="txAdvice" pointcut-ref="testDaoOperation" />
>        </aop:config>
>
> </beans>
>
> James Carman wrote:
>> You're not managing your Hibernate sessions properly.  You need to
>> make sure you close it (which will close the db connection too or at
>> least return it to the pool).  However, I would look into using
>> declarative transaction management if you're using Spring.  The
>> transaction management code will take care of opening/closing the
>> session for you.
>>
>> On Mon, Jul 28, 2008 at 11:23 AM, Stanimir Komitov
>> <st...@devbg.piranko.com> wrote:
>>> Hi,
>>>
>>> Why every time when I call HibernateDaoSupport
>>> Session.().createSQLQuery(...)... and the SharedPoolDataSource makes new
>>> one active connection, and never close it, then my maxActive
>>> connections expired and throws the exception 'Timeout waiting for idle
>>> object'?
>>>
>>> My configuration parameters are those:
>>>
>>> driver=org.postgresql.Driver
>>> url=jdbc:postgresql://xxx.xxx.xxx.xxx/xxx
>>> user=xxxxxxx
>>> password=xxxxxx
>>> maxActive=10
>>> maxIdle=8
>>> maxWait=2000
>>> testOnBorrow=true
>>> validationQuery=select 1
>>> timeBetweenEvictionRunsMillis=300000
>>>
>>> but when I`m using HibernateTemplate in the same HibernateDaoSupport the
>>> connections are managed fine and the maxActive connections did not expired!
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Problem with maxActive connections

Posted by Stanimir Komitov <st...@devbg.piranko.com>.
This is my transaction management xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
	<bean id="txManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="testSessionFactory"/>
	</bean>
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED"
				read-only="false" />
			<tx:method name="update*" propagation="REQUIRED"
				read-only="false" />
			<tx:method name="delete*" propagation="REQUIRED"
				read-only="false" />	
			<tx:method name="load*" propagation="REQUIRED"
				read-only="true" />
		</tx:attributes>
	</tx:advice>
	
	<aop:config>
		<aop:pointcut id="testDaoOperation"
			expression="execution(* org.xxx.xxx.daos.TestDAO.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="testDaoOperation" />
	</aop:config>
	
</beans>

James Carman wrote:
> You're not managing your Hibernate sessions properly.  You need to
> make sure you close it (which will close the db connection too or at
> least return it to the pool).  However, I would look into using
> declarative transaction management if you're using Spring.  The
> transaction management code will take care of opening/closing the
> session for you.
> 
> On Mon, Jul 28, 2008 at 11:23 AM, Stanimir Komitov
> <st...@devbg.piranko.com> wrote:
>> Hi,
>>
>> Why every time when I call HibernateDaoSupport
>> Session.().createSQLQuery(...)... and the SharedPoolDataSource makes new
>> one active connection, and never close it, then my maxActive
>> connections expired and throws the exception 'Timeout waiting for idle
>> object'?
>>
>> My configuration parameters are those:
>>
>> driver=org.postgresql.Driver
>> url=jdbc:postgresql://xxx.xxx.xxx.xxx/xxx
>> user=xxxxxxx
>> password=xxxxxx
>> maxActive=10
>> maxIdle=8
>> maxWait=2000
>> testOnBorrow=true
>> validationQuery=select 1
>> timeBetweenEvictionRunsMillis=300000
>>
>> but when I`m using HibernateTemplate in the same HibernateDaoSupport the
>> connections are managed fine and the maxActive connections did not expired!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Problem with maxActive connections

Posted by James Carman <ja...@carmanconsulting.com>.
You're not managing your Hibernate sessions properly.  You need to
make sure you close it (which will close the db connection too or at
least return it to the pool).  However, I would look into using
declarative transaction management if you're using Spring.  The
transaction management code will take care of opening/closing the
session for you.

On Mon, Jul 28, 2008 at 11:23 AM, Stanimir Komitov
<st...@devbg.piranko.com> wrote:
> Hi,
>
> Why every time when I call HibernateDaoSupport
> Session.().createSQLQuery(...)... and the SharedPoolDataSource makes new
> one active connection, and never close it, then my maxActive
> connections expired and throws the exception 'Timeout waiting for idle
> object'?
>
> My configuration parameters are those:
>
> driver=org.postgresql.Driver
> url=jdbc:postgresql://xxx.xxx.xxx.xxx/xxx
> user=xxxxxxx
> password=xxxxxx
> maxActive=10
> maxIdle=8
> maxWait=2000
> testOnBorrow=true
> validationQuery=select 1
> timeBetweenEvictionRunsMillis=300000
>
> but when I`m using HibernateTemplate in the same HibernateDaoSupport the
> connections are managed fine and the maxActive connections did not expired!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org