druid连接池最大连接数 druid连接池监控页面( 三 )


user_name varchar(64) not null ment '真实姓名',
email varchar(30) not null ment '用户邮箱',
nick_name varchar(45) null ment '昵称',
status tinyint not null ment '用户状态 , 1-正常 , 2-注销 , 3-冻结',
address varchar(128) null
)
ment '用户基本信息';
INSERT INTO chenrui.user_info (id, user_id, user_name, email, nick_name, status, address) VALUES (1, 80001, '张三丰', 'xxx@126.', '三哥', 1, '武当山');
INSERT INTO chenrui.user_info (id, user_id, user_name, email, nick_name, status, address) VALUES (2, 80002, '张无忌', 'yyy@126.', '', 1, null);
<?xml version="1.0" encoding="UTF-8"?>



select * from user_info


select * from user_info where id = #{id}


select * from user_info where id =1


select * from user_info where id =2


public interface UserInfoDAO {
List findAllUser();
UserInfo getUserById(@Param("id") int id);
UserInfo getUserByIdEqualOne();
UserInfo getUserByIdEqualTwo();
}
@RestController
@Slf4j
public class UserInfoController {
@Resource
private UserInfoDAO userInfoDAO;
@GetMapping(path = "/all")
public List getAllUser(){
return userInfoDAO.findAllUser();
}
@GetMapping(path = "/getUser/{id}")
public UserInfo getById(@PathVariable int id){
return userInfoDAO.getUserById(id);
}
@GetMapping(path = "/getUser/one")
public UserInfo getById1(){
return userInfoDAO.getUserByIdEqualOne();
}
@GetMapping(path = "/getUser/two")
public UserInfo getById2(){
return userInfoDAO.getUserByIdEqualTwo();
}
}
@SpringBootApplication
@MapperScan(basePackages = ".example.springdataSourcedruid.dao")
public class SpringDataSourceDruidApplication {
public static void main(String[] args) {
SpringApplication.run(SpringDataSourceDruidApplication.class, args);
}
}
访问:http://127.0.0.1:8080/druid/  , 弹出登陆界面 , 用户和密码对应我们的配置文件中设置的用户名和密码
登陆进去可以看到里面有很多监控 , 这里我们只看我们本次所关心的 , 数据源 , SQL监控 , URL监控 , 其他的可以自行研究 。
上面我们看到数据源里面的信息和我们在application.properties中配置的一致
下面我们分别执行几次 , 我们准备好的验证接口
http://127.0.0.1:8080/all
http://127.0.0.1:8080/getUser/1
http://127.0.0.1:8080/getUser/2
http://127.0.0.1:8080/getUser/one
http://127.0.0.1:8080/getUser/two
上面我们看到我们总共四个语句 , 以及四个语句的运行情况
SQL监控项上 , 执行时间、读取行数、更新行数都有区间分布 , 将耗时分布成8个区间:
0 - 1 耗时0到1毫秒的次数
1 - 10 耗时1到10毫秒的次数
10 - 100 耗时10到100毫秒的次数
100 - 1,000 耗时100到1000毫秒的次数
1,000 - 10,000 耗时1到10秒的次数
10,000 - 100,000 耗时10到100秒的次数
100,000 - 1,000,000 耗时100到1000秒的次数
1,000,000 - 耗时1000秒以上的次数
这里你可能会有疑问  , id =1和id=2怎么还是分开的 , 如果我id有一亿个 , 难道要在监控页面上有一亿条记录吗?不是应该都应该是id=?的形式吗?这里后面会讲到 , 涉及到sql合并的监控配置
这里可以很清晰的看到 , 每个url涉及到的数据库执行的信息


特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。