Getting org.hibernate.exception.JDBCConnectionException: could not execute query even through JNDI

柔情痞子 提交于 2019-11-29 08:47:40

We had the same issue in a production system with Tomcat6+Hibernate+MySQL (and Spring in our case) and the only reliable solution we found was to set the connection timeout to a large value in the MySQL configuration. I cannot remember the particulars but I believe there was an issue with the underlying commons-pool code when it verifies that pooled resource is valid.

Another possibility that we did not try was to use an alternate Connection Pooling mechanism other than DBCP. Next to try would be C3PO

Try adding tcpKeepAlive=true to the JDBC URL.

Your url is
url="jdbc:mysql://localhost:3306/hposg?autoReconnect=true&characterEncoding=UTF-8".
But autoReconnect is not recommended (here). Instead, try increasing the timeout by adding this to my.cnf:

[mysqld]
interactive_timeout=864000
wait_timeout=864000
Avinash

I faced same problem and got no proper solution. after that i follow below link for c3p0 and i got my solution. This link is very helpful for above problem

http://syntx.io/configuring-c3p0-connection-pooling-with-spring-and-hibernate/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!