出现问题如下:
org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:625)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
com.xs.hibernate.dao.CaseshowDAO.findAbout(CaseshowDAO.java:28)
com.xs.action.PageAction.index(PageAction.java:68)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 58,665,641 milliseconds ago. The last packet sent successfully to the server was 58,665,641 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3364)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1983)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2293)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
org.hibernate.loader.Loader.doQuery(Loader.java:697)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
每次出现这个问题重启tomcat服务器就又可以了,网上也有很多解决办法,但是都试验了没用,求大神解决

解决方案 »

  1.   

    hibernate也是设置了自动提交了。
    <property name="dialect">
    org.hibernate.dialect.MySQLDialect
    </property>
    <property name="connection.url">
    jdbc:mysql://localhost:......?useUnicode:true;characterEncoding:gb2312;autoReconnect:true
    </property>
    <property name="connection.username">root</property>
    <property name="connection.password">admin</property>
    <property name="connection.driver_class">
    com.mysql.jdbc.Driver
    </property>
    <property name="myeclipse.connection.profile">mysql</property>
    <property name="show_sql">false</property>
    <property name="c3p0.min_size">5</property> <property name="c3p0.max_size">100</property>
    <!-- <property name="connection.autoReconnect">true</property>
    <property name="connection.autoReconnectForPools">true</property>
    <property name="connection.is-connection-validation-required">true</property> -->
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.idle_test_period">0</property>
    <property name="hibernate.c3p0.timeout">0</property>
    <property name="hibernate.c3p0.validate">true</property>
    <property name="c3p0.idle_test_period">100</property>
    <property name="hibernate.c3p0.acquire_increment">3</property> <property name="c3p0.max_statements">200</property>
    这是我的配置。应该没问题吧 
      

  2.   

    timeout给它个正整数值试试,比如三分钟