我正在使用一個簡單的Java應用程序來處理來自瀏覽器的表記錄。我用hibernate進行DAO調用。該應用程序正常使用時工作正常。但是,當應用程序閒置1到2天時,會發生以下異常。服務器空閒後休眠會話創建異常
Caused by: java.sql.SQLException: IO Error: Connection reset
使用c3p0後,dle時間延長至10天。但我希望應用程序一直在運行。
我一直在使用Linux服務器。 JDK 1.5。 Tomcat服務器6.
我的Hibernate的配置,
的jdbc:神諭:薄:@ something.com:1789:patentmd oracle.jdbc.driver.OracleDriver
<property name="hibernate.connection.username">something</property>
<property name="hibernate.connection.password">something</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.show_sql">true</property>
<!-- <property name="hibernate.current_session_context_class">thread</property> -->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">30</property>
<property name="c3p0.max_size">5</property>
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_statements">5</property>
<property name="c3p0.timeout">180</property>
<!-- Mapping Resources. One entry should exist for each table -->
<mapping resource="com/hibernate/pojo/clientgrp/ClientGroup.hbm.xml"/>
<mapping resource="com/hibernate/pojo/applepub/Apple_Pub.hbm.xml"/>
<mapping resource="com/hibernate/pojo/prspub/Prs_Pub.hbm.xml"/>
</session-factory>
完整的堆棧跟蹤,
$$$$$$$$$$ sessionfactory is not null
Connection : true
Hibernate: select clientgrou0_.MGR_PRS_ID as MGR1_0_, clientgrou0_.MGR_PRS_NAME as MGR2_0_, clientgrou0_.MGR_CLIENT_GROUP as
MGR3_0_, clientgrou0_.UPDATE_DT as UPDATE4_0_, clientgrou0_.CREATE_DT as CREATE5_0_, clientgrou0_.DEPT_NM as DEPT6_0_ from
CLIENTGROUPS clientgrou0_
############ ClientGroupDAO.getAll() , hibernate exception org.hibernate.exception.JDBCConnectionException: could not execu
te query
ClientGroupTableHandler.getAllRecords() $$$$$$$$ exception occured 6org.hibernate.HibernateException: org.hibernate.excepti
on.JDBCConnectionException: could not execute query
ClientGroupTableHandler.Main() $$$$$$$$ exception occured 1java.lang.Exception: org.hibernate.HibernateException: org.hiber
nate.exception.JDBCConnectionException: could not execute query
java.lang.Exception: org.hibernate.HibernateException: org.hibernate.exception.JDBCConnectionException: could not execute qu
ery
at com.web.servlets.ClientGroupTableHandler.getAllRecords(ClientGroupTableHandler.java:294)
at com.web.servlets.ClientGroupTableHandler.Main(ClientGroupTableHandler.java:76)
at com.web.servlets.ClientGroupTableHandler.doPost(ClientGroupTableHandler.java:56)
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:859)
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)
Caused by: org.hibernate.HibernateException: org.hibernate.exception.JDBCConnectionException: could not execute query
at com.hibernate.dao.ClientGroupDAO.getAll(ClientGroupDAO.java:76)
at com.web.servlets.ClientGroupTableHandler.getAllRecords(ClientGroupTableHandler.java:288)
... 16 more
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
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:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at com.hibernate.dao.ClientGroupDAO.getAll(ClientGroupDAO.java:45)
... 17 more
Caused by: java.sql.SQLException: IO Error: Connection reset
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:876)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1203)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 25 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at oracle.net.ns.DataPacket.send(DataPacket.java:199)
at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:211)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:227)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1122)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
... 35 more
Blockquote
這是一個附註,但爲什麼獲得增量爲1? Oracle搶連接費用相對較高。 – MJB 2011-05-28 09:06:58