• spring+hibernate的c3p0 连接池配置 转


    网上关于C3P0在spring中的配置,几乎没有完全正确的(至少我还没发现)。查了c3p0的文档,又试验过N次。得出如下配置是正确的:


    <!-- com.mchange.v2.c3p0.ComboPooledDataSource  --> 
     <bean id="dataSource"
      class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass"
       value="oracle.jdbc.driver.OracleDriver">
      </property>
      <property name="jdbcUrl"
       value="jdbc:oracle:thin:@127.0.0.1:1521:db">
      </property>
      <property name="user" value="123"></property>
      <property name="password" value="123"></property>
      <property name="minPoolSize"><value>1</value></property>
      <property name="maxPoolSize"><value>20</value></property>
      <property name="maxIdleTime"><value>1800</value></property>
      <property name="acquireIncrement"><value>2</value></property>
      <property name="maxStatements"><value>0</value></property>
      <property name="initialPoolSize"><value>2</value></property>
      <property name="idleConnectionTestPeriod"><value>1800</value></property>
      <property name="acquireRetryAttempts"><value>30</value></property>
      <property name="breakAfterAcquireFailure"><value>true</value></property>
      <property name="testConnectionOnCheckout"><value>false</value></property>
     </bean>
    <!--   
     <bean id="dataSource"
      class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName"
       value="oracle.jdbc.driver.OracleDriver">
      </property>
      <property name="url"
       value="jdbc:oracle:thin:@221.232.148.68:1521:starmap">
      </property>
      <property name="username" value="htgis"></property>
      <property name="password" value="htgis"></property>
     </bean>
    --> 
     <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
       <ref bean="dataSource" />
      </property>
      <property name="hibernateProperties">
       <props>
        <prop key="hibernate.dialect">
         org.hibernate.dialect.Oracle9Dialect
        </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.c3p0.min_size">5</prop> 
                    <prop key="hibernate.c3p0.max_size">20</prop> 
                    <prop key="hibernate.c3p0.timeout">1800</prop> 
                    <prop key="hibernate.c3p0.max_statements">50</prop>    
        <prop key="hibernate.show_sql">false</prop>-->
       </props>
      </property>
      <property name="mappingResources">
       <list>
        <value>ht/gisoa/entity/CmppSubmitCache.hbm.xml</value>
        <value>ht/gisoa/entity/CmppDeliver.hbm.xml</value>
        <value>ht/gisoa/entity/CmppSubmit.hbm.xml</value>
        <value>ht/gisoa/entity/CmppReport.hbm.xml</value>
        <value>ht/gisoa/entity/SGpstraceinfo.hbm.xml</value>
        <value>ht/gisoa/entity/SDeviceinfo.hbm.xml</value>
        <value>ht/gisoa/entity/SLbstraceinfo.hbm.xml</value>
        <value>ht/gisoa/entity/Lbsschemainfo.hbm.xml</value>
       </list>
      </property>
     </bean>
  • 相关阅读:
    多线程、线程同步、Lock接口
    线程池、匿名内部类、创建线程
    commons-IO、多线程
    PHP的一个坑
    jquery 实现导航栏滑动效果
    浏览器加载模式:window.onload和$(document).ready()的区别(详解)
    jQuery绑定事件-多种方式实现
    baidu-fex 精彩文章
    jquery1.11 操作checkbox:全选、取消全选、获取选择元素、获取取消选择元素(总结)
    倒计时时钟-原创
  • 原文地址:https://www.cnblogs.com/kevinge/p/2790420.html
Copyright © 2020-2023  润新知