Hi David,

Thanks for your answer.

At the moment I don't have the stack trace but it something like 

# com.mysql.jdbc.CommunicationsException: Communications link failure due to 
underlying exception:
#
# ** BEGIN NESTED EXCEPTION **
#
# java.net.SocketException
# MESSAGE: Software caused connection abort: recv failed
#
# STACKTRACE:
#
# java.net.SocketException: Software caused connection abort: recv failed
# at java.net.SocketInputStream.socketRead0(Native Method)
# at java.net.SocketInputStream.read(Unknown Source)
...

I was using dbcp and I changed to c3p0 beacause I read that with c3p0 we can 
add paramters to test the connections

My config now is :

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
   <property name="driverClass" value="com.mysql.jdbc.Driver" />
   <property name="jdbcUrl" 
value="jdbc:mysql://localhost:3306/mydb?relaxAutoCommit=true&amp;autoReconnect=true"
 />
   <property name="user" value="user" />
   <property name="password" value="0000" />
   <property name="initialPoolSize" value="5" />
   <property name="minPoolSize" value="5" />
   <property name="maxPoolSize" value="20" />
   <property name="checkoutTimeout" value="1000"/>
   <property name="acquireIncrement" value="1"/>
   <property name="testConnectionOnCheckin" value="true"/>
   <property name="testConnectionOnCheckout" value="true"/>
   <property name="preferredTestQuery" value="SELECT 1"/>
   <property name="idleConnectionTestPeriod" value="60"/>
</bean>

But I get the same error

I don't know exactly the time it takes but I didn't change anything in mysql so 
I assume it's 8 hours (some hours at least). If you know how to change this 
value...

I use spring, hibernate/jpa and I am not dealing with the connections at all. I 
am just injecting the data source like this :

<!-- Creates a EntityManagerFactory for use with the Hibernate JPA provider and 
data source -->
<bean id="entityManagerFactory" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 
/>
  </property>
</bean>

If you have an idea or questions...

Thanks for you help

--- En date de : Lun 14.9.09, David Smith <d...@cornell.edu> a écrit :

De: David Smith <d...@cornell.edu>
Objet: Re: tomcat mysql dbcp Communications link failure
À: "Tomcat Users List" <users@tomcat.apache.org>
Date: Lundi 14 Septembre 2009, 4h47

Could you provide the full stack trace?  And if possible, can you
describe time it takes as it relates to the timeout of your MySQL
server?  The default timeout in MySQL is 8 hours, but is configurable. 
Also I'm assuming all the ${...} stuff is just you sanitizing the
<Resource ... /> block.  One last question ... is there any chance your
code is holding on to connections as opposed to closing them when done? 
Closing from the app's point of view is just returning the connection to
the pool for another request later.

--David

Chetouani wrote:
> Hello guys,
>
> If you can help with this problem.
>
> I have an application deployed on tomcat V6.18. It uses a mysql database.
> The problem is that after some hours the applicatiion throws an exception 
> when trying to connect to the data base.
>
> com.mysql.jdbc.CommunicationsException: Communications link failure due to 
> underlying exception
>
> I cofigured a data source using dbcp :
>
> <Resource name="jdbc/${database.datasource}" 
>         auth="Container"
>         type="javax.sql.DataSource" 
>         factory="org.apache.commons.dbcp.BasicDataSourceFactory" 
>         driverClassName="${database.driver}" 
>         url="${database.url}" 
>         username="${database.user}"
>         password="${database.password}" 
>         removeAbandoned="true"
>         removeAbandonedTimeout="300"
>         logAbandoned="true"
>         maxActive="20"
>         maxIdle="20"
>         maxWait="10000"
>         validationQuery="SELECT 1"
>         testOnBorrow="true"
>         testOnReturn="true"
>         testWhileIdle="true"/>
>
> I did some searches and it seems that the problem is that the connection pool 
> keeps the connections for a long time even if they are considered dead by 
> mysql
>
> So if you can help
>
> Thanks
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




      

Reply via email to