总结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" 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: 0idleConnectionTestPeriod:每60秒检查所有连接池中
的空闲连接。Default: 0 acquireRetryAttempts: 定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 breakAfterAcquireFailure: 获取连接失败将会引起所有等
待连接池来获取连接的线程抛出异常。但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申
明已断开并永久关闭。Default: falsetestConnectionOnCheckout:因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的时候都将校验其有效性。
建议使用idleConnectionTestPeriod或automaticTestTable等方法来提升连接测试的性能。Default: false-->
<!--bean id="dataSource" 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.Driverjdbc.url=jdbc:mysql://localhost:3306/test?
user=root&password=root&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8jdbc.username=rootjdbc.password=root
#jdbc.url=jdbc:mysql://localhost:3306/test?user=root&password=root&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
#jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
#jdbc.url=jdbc:jtds:sqlserver://localhost:1433/test;useUnicode=true&characterEncoding=GBK&characterSetResults=GBK#jdbc.username=sa
#jdbc.password=sa
#jndijndi.factory.initial=weblogic.jndi.WLInitialContextFactoryjndi.provider.url=t3://127.0.0.1:7001jndi.jndiName=jdbc/test
hibernate.properties
#hibernate.dialect=org.hibernate.dialect.SQLServerDialecthibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
#hibernate.dialect=org.hibernate.dialect.HSQLDialecthibernate.cache.use_query_cache=true
#hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProviderhibernate.cache.provider_class=org.hibernate.cache.EhCacheProviderhibernate.show_sql=tr
uehibernate.format_sql=falsehibernate.transaction.auto_close_session=truehibernate.connection.autocommit=falsehibernate.connection.isolation=2hibernate.hbm2d
dl.auto=updatehibernate.jdbc.fetch_size=50hibernate.jdbc.batch_size=25hibernate.default_batch_fetch_size=16hibernate.transaction.factory_class=org.hibernate.
transaction.JDBCTransactionFactory#hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactoryhibernate.query.factory_class=org.h
ibernate.hql.classic.ClassicQueryTranslatorFactoryhibernate.connection.release_mode=after_transactionhibernate.cache.region_prefix=hibernate.cache.testhibern
ate.default_schema=test