1. 程式人生 > >druid 專案的sql執行速度效率監控的配置

druid 專案的sql執行速度效率監控的配置

在jdbc.properties中配置連線引數

#druid dataSource pool
druid.mysql.driver = com.mysql.jdbc.Driver
druid.initialSize = 3
druid.maxActive = 20
druid.maxIdle=5
druid.minIdle = 2
druid.maxWait = 60000
druid.removeAbandoned = true
druid.removeAbandonedTimeout = 180
druid.timeBetweenEvictionRunsMillis = 60000
druid.minEvictableIdleTimeMillis = 300000
druid.validationQuery = SELECT 1 FROM DUAL
druid.testWhileIdle = false
druid.testOnBorrow = false
druid.testOnReturn = false
druid.poolPreparedStatements = true
druid.maxPoolPreparedStatementPerConnectionSize = 20
filters =stat
 

#è¿æ¥è®¾ç½®
case.jdbc.url=jdbc:mysql://127.0.0.1:3306/cuiji?useUnicode\=true&characterEncoding\=utf-8&zeroDateTimeBehavior\=convertToNull
case.jdbc.username=root
case.jdbc.password=root


在web.xml中配置druid外掛的配置

<!-- 德魯伊sql 監控 -->
<!-- 地址:http://域名:埠號/druid/sql.html -->
<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>
<filter>
<filter-name>druidWebStatFilter</filter-name>
<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>/public/*,*.js,*.css,/druid*,*.jsp,*.swf</param-value>
</init-param>
<init-param>
<param-name>principalSessionName</param-name>
<param-value>sessionInfo</param-value>
</init-param>
<init-param>
<param-name>profileEnable</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>druidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


在web端檢視慢sql執行速度: