Druid连接池配置


    com.alibaba
    druid
    1.0.18


jdbc.xml
xml version="1.0" encoding="UTF-8" standalone="no"?>


    
key="druid.jdbcUrl">jdbc:mysql://localhost:3306/joinbus?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useLocalSessionState=true

key="druid.username">dev

key="druid.password">dev

key="druid.driverClass">com.mysql.jdbc.Driver

key="druid.initialSize" >5

key="druid.maxActive">10

key="druid.maxIdle">20

key="druid.minIdle">3

key="druid.maxWait">60000

key="druid.removeAbandoned">true

key="druid.removeAbandonedTimeoutMillis">180000

key="druid.timeBetweenEvictionRunsMillis">60000

key="druid.minEvictableIdleTimeMillis">300000

key="druid.validationQuery">select 1

key="druid.testWhileIdle">true

key="druid.testOnBorrow">false

key="druid.testOnReturn">false

key="druid.poolPreparedStatements">true
key="druid.maxPoolPreparedStatementPerConnectionSize">50

key="druid.filters">stat
 
id="targetDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">

name="driverClassName" value="${druid.driverClass}"/>

name="url" value="${druid.jdbcUrl}"/>

name="username" value="${druid.username}"/>

name="password" value="${druid.password}"/>

name="initialSize" value="${druid.initialSize}"/>

name="maxActive" value="${druid.maxActive}"/>

  
    
name="minIdle" value="${druid.minIdle}"/>

name="maxWait" value="${druid.maxWait}"/>

name="removeAbandoned" value="${druid.removeAbandoned}"/>

name="removeAbandonedTimeoutMillis" value="${druid.removeAbandonedTimeoutMillis}"/>

name="timeBetweenEvictionRunsMillis" value="${druid.timeBetweenEvictionRunsMillis}"/>

name="minEvictableIdleTimeMillis" value="${druid.minEvictableIdleTimeMillis}"/>

name="validationQuery" value="${druid.validationQuery}"/>

name="testWhileIdle" value="${druid.testWhileIdle}"/>

name="testOnBorrow" value="${druid.testOnBorrow}"/>

name="testOnReturn" value="${druid.testOnReturn}"/>

name="poolPreparedStatements" value="${druid.poolPreparedStatements}"/>
    name="maxPoolPreparedStatementPerConnectionSize" value="${druid.maxPoolPreparedStatementPerConnectionSize}"/>

name="filters" value="${druid.filters}"/>
 
   

 

然后是监控的配置:

web.xml

 

  1.        
  2.         DruidWebStatFilter  
  3.         com.alibaba.druid.support.http.WebStatFilter  
  4.           
  5.             exclusions  
  6.             *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*  
  7.           
  8.         
  9.         
  10.         DruidWebStatFilter  
  11.         /*  
  12.         

 

filter可以监控webURl 访问

 

  1.       
  2.         DruidStatView  
  3.         com.alibaba.druid.support.http.StatViewServlet  
  4.       
  5.       
  6.         DruidStatView  
  7.         /druid/*  
  8.       

 

访问监控页面:http://localhost:8080/druid/index.html

你可能感兴趣的:(mysql,数据库,web.xml,java)