tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: tomcat mysql dbcp Communications link failure
Date Wed, 16 Sep 2009 21:07:13 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chetouani,

On 9/15/2009 6:38 PM, Chetouani wrote:
> 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:

Right: your JDBC connection was closed and needs to be re-built.

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

All connection pools I know of support this, including the stock
commons-dbcp. Switching to c3p0 was not necessary -- at least not for
this reason.

>    <property name="testConnectionOnCheckin" value="true"/>
>    <property name="testConnectionOnCheckout" value="true"/>
>    <property name="preferredTestQuery" value="SELECT 1"/>

This would seem to be the correct configuration. You might want to add
this to your MySQL connection URL:

&dumpQueriesOnException=true

This may allow you figure out which query is failing (whether it's the
"SELECT 1" test query that is failing, or if it's an application query
that is failing).

> 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>

I don't know enough about Spring DataSources to know if this is
appropriate, but if you can get JDBC connections from this thing, your
configuration appears to be correct.

Is it possible that you have more than one connection pool, and that you
are re-configuring the wrong one?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqxU4EACgkQ9CaO5/Lv0PC5BgCdHLUv/lahiEmvkA55yE2MHJTN
1EMAnAiuRt+L75lc3Q3NxNoMkWQL4bvo
=tpHe
-----END PGP SIGNATURE-----

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


Mime
View raw message