spring中datasource配置
datasource配置有很多种,我介绍的一种是采用c3p0的,它的百科地址是:
http://baike.baidu.com/view/920062.htm
?
<!-- spring加载资源文件 --><bean name="propertiesConfig"value="${datasource.driverClassName}" /><property name="jdbcUrl" value="${datasource.url}" /><property name="user" value="${datasource.user}" /><property name="password" value="${datasource.password}" /><property name="minPoolSize" value="${datasource.minPoolSize}" /><property name="maxPoolSize" value="${datasource.maxPoolSize}" /><property name="maxIdleTime" value="${datasource.maxIdleTime}" /><property name="acquireIncrement" value="${datasource.acquireIncrement}" /><property name="maxStatements" value="${datasource.maxStatements}" /><property name="initialPoolSize" value="${datasource.initialPoolSize}" /><property name="idleConnectionTestPeriod" value="${datasource.idleConnectionTestPeriod}" /><property name="acquireRetryAttempts" value="${datasource.acquireRetryAttempts}" /><property name="breakAfterAcquireFailure" value="${datasource.breakAfterAcquireFailure}" /><property name="testConnectionOnCheckout" value="${datasource.testConnectionOnCheckout}" /></bean>
?下面是jdbc.properties的配置:
#datasource.driverClass=oracle.jdbc.driver.OracleDriverdatasource.driverClassName=com.mysql.jdbc.Driverdatasource.url=jdbc\:mysql\://192.168.1.1\:3306/xxxdatasource.user=rootdatasource.password=123456#Optionaldatasource.minPoolSize=1datasource.maxPoolSize=50datasource.maxIdleTime=25000datasource.acquireIncrement=2datasource.maxStatements=0datasource.initialPoolSize=2datasource.idleConnectionTestPeriod=25000datasource.acquireRetryAttempts=30datasource.breakAfterAcquireFailure=truedatasource.testConnectionOnCheckout=true
?