druid接続プール構成関連

2420 ワード

1.druid取得
2.druid公式ドキュメント
3.druid構成
jdbc.properties
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://127.0.0.1:3306/employee
username=root
password=xxx
filters=stat
initialSize=2
maxActive=300
maxWait=60000
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
validationQuery=SELECT 1
testWhileIdle=true
testOnBorrow=false
testOnReturn=false
poolPreparedStatements=false
maxPoolPreparedStatementPerConnectionSize=200

applicationContext.xmlでのdataSource構成
<!--       :    Druid   -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close" init-method="init" >
	<property name="url" value="${url}"></property>
	<property name="driverClassName" value="${driverClassName}"></property>
	<property name="username" value="${username}"></property>
	<property name="password" value="${password}"></property>
	<property name="filters" value="${filters}"></property>
	<property name="maxActive" value="${maxActive}"></property>
	<property name="maxWait" value="${maxWait}"></property>
	<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}"></property>
	<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}"></property>
	<property name="validationQuery" value="${validationQuery}"></property>
	<property name="testWhileIdle" value="${testWhileIdle}"></property>
	<property name="testOnBorrow" value="${testOnBorrow}"></property>
	<property name="testOnReturn" value="${testOnReturn}"></property>
	<property name="poolPreparedStatements" value="${poolPreparedStatements}"></property>
	<property name="maxPoolPreparedStatementPerConnectionSize" value="${maxPoolPreparedStatementPerConnectionSize}"></property>
</bean>