日期:2014-05-18  浏览次数:20645 次

hibernate3使用了一段时间以后,Connection reset 无法连接数据库
APP:ORACLE   10G   application   Server
DB:ORACLE   10G
表示层使用STRUTS,持久化层直接使用hibernate3,没有用spring进行管理
连接使用APP   server的DATASOURCE   进行连接

每次调用数据连接时,都会用HibernateSessionFactory.getCurrentSession()去取
使用后都会用,HibernateSessionFactory.closeSession()去释放连接

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

<hibernate-configuration>
<session-factory>
<property   name= "connection.datasource "> java:comp/env/jdbc/OracleDS </property>
<property   name= "hibernate.dialect "> org.hibernate.dialect.Oracle9Dialect </property>
<property   name= "hibernate.jdbc.fetch_size "> 50 </property>
<property   name= "hibernate.jdbc.batch_size "> 30 </property>
<property   name= "hibernate.query.factory_class "> org.hibernate.hql.classic.ClassicQueryTranslatorFactory </property>
<property   name= "hibernate.show_sql "> true </property>

=========================================================================

使用了一段时间以后,页面会报错,但刷新一下又会恢复正常
再使用一段时间以后,数据连接就会断掉,刷新也无法恢复正常
只有重起APP的服务才能恢复正常

后台LOG信息报错如下
2007-07-16   13:35:15,556   ERROR   [org.hibernate.util.JDBCExceptionReporter]   -   Io   exception:   Connection   reset  
 
org.hibernate.exception.GenericJDBCException:   could   not   execute   query  
 
        at   org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)  
 
        at   org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)  
 
        at   org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)  
 
        at   org.hibernate.loader.Loader.doList(Loader.java:2223)  
 
        at   org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)  
 
        at   org.hibernate.loader.Loader.list(Loader.java:2099)  
 
        at   org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)  
 
        at   org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)  
 
        at   org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)  
 
        at   com.dianda.database.HibernateBaseDao.find(HibernateBaseDao.java:256)  
 
        at   com.dianda.product.Product.getLatestProduct(Product.java:205)  
 
        at