com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链路故障6

时间:2013-02-13 09:04:59

标签: mysql spring hibernate

在日志中,我遇到以下异常。可能的原因是什么? 应用程序有Spring 3.1,hibernate 3.6.9和最新的mysql。

        11:54:25,158 ERROR LoginController:152 - org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed: 
            at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:427)
            at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
            at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
            .....
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
            at java.lang.Thread.run(Thread.java:722)
        Caused by: javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed: 
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
            at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
            at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1225)
            at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:63)
            at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)
            at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:377)
            ... 50 more
        Caused by: org.hibernate.TransactionException: JDBC begin failed: 
            at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:92)
            at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
            at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:60)
            ... 52 more
        Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

2 个答案:

答案 0 :(得分:0)

看起来你丢失了MySQL连接。这可能是MySQL方面的网络问题或问题。

答案 1 :(得分:0)

在persistence.xml中实现连接池(C3PO)后得到解决