Re: tomcat mysql dbcp Communications link failure
-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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: tomcat mysql dbcp Communications link failure
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=trueamp;autoReconnect=true / property name=user value=user / property name=password value= / 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=1 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
tomcat mysql dbcp Communications link failure
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=1 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
Re: tomcat mysql dbcp Communications link failure
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=1 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