<hibernate-configuration>
<session-factory>

<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<!--Fetch Size 是设定JDBC的Statement读取数据的时候每次从数据库中取出的记录条数-->
<property name="jdbc.fetch_size">20</property>
<!--Batch Size是设定对数据库进行批量删除,批量更新和批量插入的时候的批次大小,有点相当于设置Buffer缓冲区大小的意思-->
<property name="jdbc.batch_size ">20</property>
<property name="connection.username">HNMC</property>
<property name="connection.password">sundy</property>
<property name="connection.url">jdbc:oracle:thin:@192.168.0.20:1521:ora9</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

<!--  在这种情况下,没问题啊 -->
<property name="c3p0.timeout">60</property>
<property name="c3p0.idle_test_period">600</property>


<!--    

<!--<property name="c3p0.idle_test_period">120</property>-->
如改以下俩值,或他们差距很大:

<property name="c3p0.timeout">600</property>

<!--<property name="c3p0.idle_test_period">60</property>-->

当我启动tomcat,运行程序后,空闲600后出现下列异常,但程序还照常运行

-->

<!-- 

Hibernate里可以设置的属性不多:
#c3p0-native property name hibernate configuration key
#c3p0.acquireIncrement hibernate.c3p0.acquire_increment
#c3p0.idleConnectionTestPeriod hibernate.c3p0.idle_test_period
#c3p0.initialPoolSize not available -- uses minimum size
#c3p0.maxIdleTime hibernate.c3p0.timeout
#c3p0.maxPoolSize hibernate.c3p0.max_size
#c3p0.maxStatements hibernate.c3p0.max_statements
#c3p0.minPoolSize hibernate.c3p0.min_size
#c3p0.testConnectionsOnCheckout hibernate.c3p0.validate hibernate 2.x only!

另外的属性你需要配置c3p0.properties
比如:
c3p0.acquireRetryDelay=111
c3p0.acquireRetryAttempts=22
c3p0.breakAfterAcquireFailure=true

-->



<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">2</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">50000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>

<!-- 另<property name="hibernate.c3p0.validate">false</property>确实在hibernate中不可设置  -->
<property name="hibernate.c3p0.validate">false</property>


<!--C3P0 setting-->

<property name="c3p0.max_size">20</property>
<property name="c3p0.min_size">5</property>
<!--获取连接的等待时间-->
<property name="c3p0.timeout">3600</property>
<property name="c3p0.max_statements">100</property>
<!--每隔3600毫秒测试连接是否可以正常使用-->
<property name="c3p0.idle_test_period">3600</property>
<property name="c3p0.acquire_increment">2</property>

<mapping resource="com/sundy/hnmc/beans/AccountBean.hbm.xml"/>
</session-factory>
</hibernate-configuration>



另一个设置
 <!-- 数据源配置 -->
    
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
      
<property name="driverClass">
        
<value>org.gjt.mm.mysql.Driver</value>
      
</property>
      
<property name="jdbcUrl">
        
<value>jdbc:mysql://localhost/tycho?useUnicode=true&amp;characterEncoding=utf-8</value>
      
</property>
      
<property name="properties">
        
<props>
            
<prop key="hibernate.hbm2ddl.auto">update</prop> 
            
<prop key="c3p0.minPoolSize">1</prop> 
            
<prop key="hc3p0.maxPoolSize">10</prop> 
            
<prop key="hc3p0.timeout">60</prop> 
            
<prop key="c3p0.max_statement">50</prop> 
            
<prop key="c3p0.testConnectionOnCheckout">true</prop> 
            
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
            
<prop key="user">root</prop> 
            
<prop key="password">root</prop>
        
</props>
      
</property>
    
</bean>



<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.timeout">120</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">120</property>
<property name="hibernate.c3p0.acquire_increment">2</property>