丢掉丑陋的DBCP 用上高大上的druid

<beans profile="production">
 		<context:property-placeholder ignore-unresolvable="true"
			location="classpath:/jdbc.properties" />	
		

		
		<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close" >

			<property name="url" value="${url}" />
			<property name="username" value="doccustom" />
			<property name="password" value="..." />
			<property name="driverClassName" value="${driverClassName}" />
			<property name="filters" value="${filters}" />
			 
			<property name="maxActive" value="${maxActive}" />
			<property name="initialSize" value="${initialSize}" />
			<property name="maxWait" value="${maxWait}" />
			<property name="minIdle" value="${minIdle}" />
			 
			<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
			<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
			 
			<property name="validationQuery" value="${validationQuery}" />
			<property name="testWhileIdle" value="${testWhileIdle}" />
			<property name="testOnBorrow" value="${testOnBorrow}" />
			<property name="testOnReturn" value="${testOnReturn}" />
			<property name="poolPreparedStatements" value="${poolPreparedStatements}" />
			<property name="maxOpenPreparedStatements" value="${maxOpenPreparedStatements}" />
			<property name="removeAbandoned" value="${removeAbandoned}" /> <!-- 打开removeAbandoned功能 -->
			<property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" /> <!-- 1800秒,也就是30分钟 -->
			<property name="logAbandoned" value="${logAbandoned}" /> <!-- 关闭abanded连接时输出错误日志 -->
		</bean>
		
		
		

	</beans>

url=jdbc\:oracle\:thin\:@localhost\:1521\:orcl
driverClassName=oracle.jdbc.driver.OracleDriver
username=doccustom
password=...
filters=stat,log4j,wall
maxActive=20
initialSize=1
maxWait=60000
minIdle=10
timeBetweenEvictionRunsMillis=60000
minEvictableIdleTimeMillis=300000
validationQuery=SELECT * from 'auth_user'
testWhileIdle=true
testOnBorrow=false
testOnReturn=false
poolPreparedStatements=true
maxOpenPreparedStatements=20
removeAbandoned=true
removeAbandonedTimeout=1800
logAbandoned=true
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect

web.xml

<servlet>
		<servlet-name>DruidStatView</servlet-name>
		<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>DruidStatView</servlet-name>
		<url-pattern>/druid/*</url-pattern>
	</servlet-mapping>


WIKI地址

https://github.com/alibaba/druid/wiki/


你可能感兴趣的:(丢掉丑陋的DBCP 用上高大上的druid)