Druid连接池的基本配置
<!-- 阿里 druid 数据库连接池 -->
< bean id = "dataSource" class = "com.alibaba.druid.pool.DruidDataSource"destroy-method = "close" >
<!-- 数据库基本信息配置 -->
< property name = "url" value = "${url}" />
< property name = "username" value = "${username}" />
< property name = "password" value = "${password}" />
< 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 = "maxOpenPreparedStatements" value ="${maxOpenPreparedStatements}" />
<!-- 打开 removeAbandoned 功能 -->
< property name = "removeAbandoned" value = "${removeAbandoned}" />
<!-- 1800 秒,也就是 30 分钟 -->
< property name = "removeAbandonedTimeout" value ="${removeAbandonedTimeout}" />
<!-- 关闭 abanded 连接时输出错误日志 -->
< property name = "logAbandoned" value = "${logAbandoned}" />
</ bean >
http://repo1.maven.org/maven2/com/alibaba/druid/ 下载最新的jar包。如果想使用最新的源码编译,可以从 https://github.com/alibaba/druid 下载源码
温馨提示:
Druid 是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,
包括 DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。
Druid 已经在阿里巴巴部署了超过 600 个应用,经过多年多生产环境大规模部署的严苛考验。