为什么要使用durid SQL 监控
1 简单的操作数据库通常涉及datasource,connection,preparedstatement ,ResultSet等东西,如果我要监控这些,必然要建些代理类。
废话不多说,直接上代码
1: pom.xml。
|
|
2:添加 Druid的StatFilter1234567891011121314151617181920 import javax.servlet.annotation.WebFilter;import javax.servlet.annotation.WebInitParam;import com.alibaba.druid.support.http.WebStatFilter;/** * Druid的StatFilter * * @author */ initParams={})public class DruidStatFilter extends WebStatFilter {}
3:添加 Druid的StatViewServlet12345678910111213141516171819202122import javax.servlet.annotation.WebInitParam;import javax.servlet.annotation.WebServlet;import com.alibaba.druid.support.http.StatViewServlet;/** * StatViewServlet * */ initParams={ })public class DruidStatViewServlet extends StatViewServlet {}