Hibernate连接超时 - java.io.EOFException

时间:2011-11-26 03:00:48

标签: java hibernate tomcat c3p0

开始连接2天后会抛出异常......

  

SEVERE:servlet的Servlet.service()接收异常   org.hibernate.exception.JDBCConnectionException:无法执行查询           在org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)           在org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)           在org.hibernate.loader.Loader.doList(Loader.java:2235)           在org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)           在org.hibernate.loader.Loader.list enter code here(Loader.java:2124)           在org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)           在org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)           在org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)           在org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)           在org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)           在com.appzone.chatrooms.dao.MemberDao.getStatus(MemberDao.java:237)           在com.appzone.chatrooms.Sender.sendResponse(Sender.java:53)           在com.appzone.chatrooms.Service.sender(Service.java:337)           在com.appzone.chatrooms.Service.chat(Service.java:32)           在com.appzone.chatrooms.Main.Controller(Main.java:59)           在com.appzone.chatrooms.Reciever.onMessage(Reciever.java:27)           at> hsenidmobile.sdp.rest.servletbase.MchoiceAventuraSmsMoServlet.doPost(MchoiceAventuraSmsMoServlet.java:67)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:637)           在javax.servlet.http.HttpServlet.service(HttpServlet.java:717)           在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)           在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)           在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)           在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)           在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)           在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)           在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)           在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588)           在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)           在java.lang.Thread.run(Thread.java:619)       引起:com.mysql.jdbc.CommunicationsException:由于底层异常导致通信链接失败:

 **BEGIN NESTED EXCEPTION** 

**java.io.EOFException**

**STACKTRACE:**

>java.io.EOFException**
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1845)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1812)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1657)
    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
    at org.hibernate.loader.Loader.doQuery(Loader.java:697)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
    at org.hibernate.loader.Loader.doList(Loader.java:2232)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
    at org.hibernate.loader.Loader.list(Loader.java:2124)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at com.appzone.chatrooms.dao.MemberDao.getStatus(MemberDao.java:237)
    at com.appzone.chatrooms.Sender.sendResponse(Sender.java:53)
    at com.appzone.chatrooms.Service.sender(Service.java:337)
    at com.appzone.chatrooms.Service.chat(Service.java:32)
    at com.appzone.chatrooms.Main.Controller(Main.java:59)
    at com.appzone.chatrooms.Reciever.onMessage(Reciever.java:27)
    at hsenidmobile.sdp.rest.servletbase.MchoiceAventuraSmsMoServlet.doPost(MchoiceAventuraSmsMoServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)

这是hibernate.cfg.xml文件

      <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

    <hibernate-configuration>
        <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/chatrooms</property>
        <property name="hibernate.connection.username">username</property>
        <property name="hibernate.connection.password">password</property>
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.hbm2ddl.auto">update</property>

        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">100</property>
        <property name="hibernate.c3p0.timeout">300</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>

        <!-- Mapping files -->
        <mapping class="com.appzone.chatrooms.Member" />
        <mapping class="com.appzone.chatrooms.Room" />
    </session-factory>
</hibernate-configuration>

我找不到这个错误的解决方案...有什么建议吗?

1 个答案:

答案 0 :(得分:0)

这个帖子暗示它可能是@aishwarya提到的超时问题

http://www.zkoss.org/forum/listComment/7856