<!-- 阿裡 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 個應用,經過多年多生產環境大規模部署的嚴苛考驗。