zoukankan      html  css  js  c++  java
  • 总结spring下配置dbcp,c3p0,proxool数据源链接池

    转载自 http://hiok.blog.sohu.com/66253191.html

    applicationContext-datasource-jdbc.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE beans PUBLIC     "-//SPRING//DTD BEAN//EN"     "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans default-autowire="no" default-lazy-init="true"  default-dependency-check="none">  <description>datasource</description> <!--      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">   <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>   <property name="url"><value>${jdbc.url}</value></property>   <property name="username"><value>${jdbc.username}</value></property>   <property name="password"><value>${jdbc.password}</value></property>  </bean> -->

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>     <property name="url"><value>${jdbc.url}</value></property>     <property name="username"><value>${jdbc.username}</value></property>     <property name="password"><value>${jdbc.password}</value></property>     <property name="maxActive"><value>80</value></property>      <property name="maxIdle"><value>20</value></property>      <property name="maxWait"><value>3000</value></property>      </bean>

     

     <!--bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">         <property name="driverClass"><value>${jdbc.driverClassName}</value></property>         <property name="jdbcUrl"><value>${jdbc.url}</value></property>         <property name="user"><value>${jdbc.username}</value></property>         <property name="password"><value>${jdbc.password}</value></property>          <property name="acquireIncrement"><value>5</value></property>         <property name="idleConnectionTestPeriod"><value>3000</value></property>         <property name="checkoutTimeout"><value>3000</value></property>         <property name="maxPoolSize"><value>80</value></property>         <property name="minPoolSize"><value>1</value></property>         <property name="maxStatements"><value>6000</value></property>         <property name="initialPoolSize"><value>5</value></property>  </bean-->   <!-- ComboPooledDataSource 参数说明

    maxIdleTime: 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 acquireIncrement: 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 maxStatements: JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements 属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。 如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 idleConnectionTestPeriod: 每60秒检查所有连接池中的空闲连接。Default: 0 acquireRetryAttempts: 定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 breakAfterAcquireFailure: 获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效 保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试 获取连接失败后该数据源将申明已断开并永久关闭。Default: false testConnectionOnCheckout: 因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的 时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable 等方法来提升连接测试的性能。Default: false -->

     

     <!--bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close">   <property name="driver"><value>${jdbc.driverClassName}</value></property>   <property name="driverUrl"><value>${jdbc.url}</value></property>   <property name="user"><value>${jdbc.username}</value></property>   <property name="password"><value>${jdbc.password}</value></property>   <property name="alias"><value>test</value></property>   <property name="houseKeepingSleepTime"><value>90000</value></property>   <property name="prototypeCount"><value>10</value></property>   <property name="maximumConnectionCount"><value>100</value></property>   <property name="minimumConnectionCount"><value>10</value></property>   <property name="trace"><value>true</value></property>   <property name="verbose"><value>true</value></property>  </bean>  -->

    </beans>

    jdbc.properties

     

    #jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver #jdbc.url=jdbc:jtds:sybase://192.168.1.1:5000/test;charset=eucgb #jdbc.username=test #jdbc.password=test

     

    #jdbc.driverClassName=org.hsqldb.jdbcDriver #jdbc.url=jdbc:hsqldb:file:hsqldb/test #jdbc.username=sa #jdbc.password=

    jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/test?user=root&password=root&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 jdbc.username=root jdbc.password=root

     

    #jdbc.url=jdbc:mysql://localhost:3306/test?user=root&amp;password=root&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8

     

    #jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver #jdbc.url=jdbc:jtds:sqlserver://localhost:1433/test;useUnicode=true&amp;characterEncoding=GBK&amp;characterSetResults=GBK #jdbc.username=sa #jdbc.password=sa

    #jndi jndi.factory.initial=weblogic.jndi.WLInitialContextFactory jndi.provider.url=t3://127.0.0.1:7001 jndi.jndiName=jdbc/test


    hibernate.properties

    #hibernate.dialect=org.hibernate.dialect.SQLServerDialect hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect #hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.cache.use_query_cache=true #hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.show_sql=true hibernate.format_sql=false hibernate.transaction.auto_close_session=true hibernate.connection.autocommit=false hibernate.connection.isolation=2 hibernate.hbm2ddl.auto=update hibernate.jdbc.fetch_size=50 hibernate.jdbc.batch_size=25 hibernate.default_batch_fetch_size=16 hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory #hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory hibernate.connection.release_mode=after_transaction hibernate.cache.region_prefix=hibernate.cache.test hibernate.default_schema=test

  • 相关阅读:
    [Aaronyang] 写给自己的WPF4.5 笔记23 [3d交互与动画 4/4]
    [Aaronyang] 写给自己的WPF4.5 笔记22 [3d交互与动画 3/4]
    [Aaronyang] 写给自己的WPF4.5 笔记21 [3d课 2/4]
    [Aaronyang] 写给自己的WPF4.5 笔记20 [3d课 1/4]
    [Aaronyang] 写给自己的WPF4.5 笔记19[Visual类图文并茂讲解]
    [Aaronyang] 写给自己的WPF4.5 笔记18[几何图形*Geometry图文并茂讲解]
    [Aaronyang紫色博客] 写给自己的WPF4.5-Blend5公开课系列 3
    [Aaronyang紫色博客] 写给自己的WPF4.5-Blend5公开课系列 2-更进一步
    [Aaronyang紫色博客] 写给自己的WPF4.5-Blend5公开课系列 1
    [Aaronyang] 写给自己的WPF4.5 笔记15[AyArc诞生-WPF版本绚丽的环状图,Ay制作,AyWindow强势预览]
  • 原文地址:https://www.cnblogs.com/new0801/p/6175983.html
Copyright © 2011-2022 走看看