2012-06-21 83 views
0

我的Web應用程序(Java jsf icefaces - jboss)使用hibernate連接到Oracle。它工作正常,但如果有用戶不活動的時間段(一些小時),當用戶試圖進行查詢時,發生此錯誤: java.sql.SQLException:Io異常:通過對等方重置連接:套接字寫入錯誤通過休眠連接到Oracle

該應用程序由3/4個用戶使用,因此打開的連接數量非常少。 我可以解決重新啓動jboss服務器的問題。

下面顯示的應用程序使用的hibernate.cfg.xml中:

<?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">portaleClientiOracleDS</property> -->  
     <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
     <property name="current_session_context_class">thread</property> 
     <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
     <property name="hibernate.connection.password">Alfre$cost12</property> 
     <property name="hibernate.connection.url">jdbc:oracle:thin:@172.16.216.109:1521:ALFHIST</property> 
     <property name="hibernate.connection.username">ALFRESCOST</property> 
     <!-- <property name="hibernate.default_catalog">ALFRESCOST</property>--> 
     <!-- <property name="hibernate.default_schema">ALFRESCOST</property>--> 
     <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> 
     <property name="show_sql">false</property> 
     <property name="use_outer_join">true</property> 
     <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> 

     <property name="c3p0.acquire_increment">1</property> 
     <property name="c3p0.idle_test_period">100</property> <!-- seconds --> 
     <property name="c3p0.max_size">100</property> 
     <property name="c3p0.max_statements">0</property> 
     <property name="c3p0.min_size">10</property> 
     <property name="c3p0.timeout">100</property> 
     <property name="c3p0.preferredTestQuery">SELECT 1 FROM DUAL</property> 
     <property name="c3p0.testConnectionOnCheckout">true</property> 

     <mapping resource="it/pillar/accenture/portaleclienti/businesslayer/clienti/dao/hibernate/mappings/StoricoPillar.hbm.xml"/>  

    </session-factory>  
</hibernate-configuration> 

我試圖增加C3P0值,但問題依然完好。任何建議表示讚賞

謝謝

回答

1

你可能沒有使用c3p0。 The documentation說:

Hibernate will use its org.hibernate.connection.C3P0ConnectionProvider for connection pooling if you set hibernate.c3p0.* properties. If you would like to use Proxool, refer to the packaged hibernate.properties and the Hibernate web site for more information.

The following is an example hibernate.properties file for c3p0:

hibernate.connection.driver_class = org.postgresql.Driver 
hibernate.connection.url = jdbc:postgresql://localhost/mydatabase 
hibernate.connection.username = myuser 
hibernate.connection.password = secret 
hibernate.c3p0.min_size=5 
hibernate.c3p0.max_size=20 
hibernate.c3p0.timeout=1800 
hibernate.c3p0.max_statements=50 
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect 

所以性能應該是hibernate.c3p0.xxx而不是c3p0.xxx

+0

感謝您的留言。不幸的是,它沒有解決問題...我注意到,當用戶嘗試進行查詢時,發生的第一個錯誤是: java.sql.SQLException:Io異常:讀取超時 然後,如果用戶發出另一個查詢,錯誤是 java.sql.SQLException:Io異常:通過peer重置連接:套接字寫入錯誤 我要瘋了.... – Michele