随笔-153  评论-235  文章-19  trackbacks-0
参考:(willpower88兄的blog) http://www.blogjava.net/willpower88/archive/2007/01/10/92928.html

当我spring中用c3p0时第一次老出现
org.hibernate.exception.JDBCConnectionException: could not execute query
刷新后就不会。一番折腾后直接用<property name="" value="" />就可以了。随后找到willpower88兄的blog他总结得很好。

环境:
spring 2.0
c3p0-0.9.0.4

spring配置文件如下(引用willpower88兄的,注释掉的都有问题的):

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"   destroy-method="close">
         
<property name="driverClass" value="com.mysql.jdbc.Driver" />
         
<property name="jdbcUrl" value="jdbc:mysql://localhost/test"/>            
         
<property name="user" value="root"/>
         
<property name="password" value=""/>
          
         
<property name="minPoolSize" value="2"/>
         
<property name="maxPoolSize" value="20"/>
         
<property name="maxIdleTime" value="1800"/>
         
<property name="acquireIncrement" value="2"/>
         
<property name="maxStatements" value="0"/>
         
<property name="initialPoolSize" value="3"/>
         
<property name="idleConnectionTestPeriod" value="1800"/>
         
<property name="acquireRetryAttempts" value="30"/>
         
<property name="breakAfterAcquireFailure" value="true"/>
         
<property name="testConnectionOnCheckout" value="false"/>
         
         
<!-- 
         <property name="properties">
          <props>              
              <prop key="c3p0.minPoolSize">1</prop> 
              <prop key="c3p0.maxPoolSize">10</prop> 
              <prop key="c3p0.maxIdleTime">1800</prop>              
              <prop key="c3p0.acquireIncrement">2</prop> 
              <prop key="c3p0.maxStatements">0</prop> 
              <prop key="c3p0.initialPoolSize">2</prop>
              <prop key="c3p0.idleConnectionTestPeriod">1800</prop>
              <prop key="c3p0.acquireRetryAttempts">30</prop>
              <prop key="c3p0.breakAfterAcquireFailure">true</prop>
              <prop key="c3p0.testConnectionOnCheckout">true</prop>
              <prop key="user">root</prop>
              <prop key="password">999999</prop>
              
          </props>
         </property>
        
-->      
</bean>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  
<property name="dataSource" ref="dataSource"/>
  
<property name="mappingDirectoryLocations">
      
<list>
   
<value>classpath:/com/licaionline/domain/</value>
      
</list>
  
</property>
  
<property name="hibernateProperties">
   
<props>
     
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
     
<prop key="hibernate.show_sql">true</prop>
     
<prop key="hibernate.generate_statistics">true</prop>
     
<prop key="hibernate.connection.release_mode">auto</prop>                      
     
<prop key="hibernate.autoReconnect">true</prop>
     
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<!-- 
    <prop key="hibernate.useUnicode"></prop> 
    <prop key="hibernate.characterEncoding"></prop>
    <prop key="hibernate.default-lazy-init"></prop>
    <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>     
 
-->
                                
<!--
    <prop key="hibernate.c3p0.acquire_increment">2</prop>
    <prop key="hibernate.c3p0.idle_test_period">1800</prop>
    <prop key="hibernate.c3p0.timeout">1800</prop>
    <prop key="hibernate.c3p0.max_size">30</prop>
    <prop key="hibernate.c3p0.min_size">2</prop>
    <prop key="hibernate.c3p0.max_statements">50</prop>
-->         
   
</props>
  
</property>
</bean>
posted on 2007-03-18 17:06 流浪汗 阅读(2564) 评论(0)  编辑  收藏 所属分类: Spring

只有注册用户登录后才能发表评论。


网站导航: