zoukankan      html  css  js  c++  java
  • jdbc事务并发现象

    1、脏读


    1.1避免脏读现象

    #避免脏读
    
    #开启事务A
    start transaction;
    #关闭自动提交
    set @@autocommit = 0
    show variables like '%autocommit%'
    update student set name = 'kangkang232' where id =1;
    select * from student where id =1
    rollback;
    commit;
    #开启事务B
    start transaction;
    #设置隔离级别为读已提交
    set session transaction isolation level read committed;
    select * from student where id =1
    commit;

    2、不可重复读


    #避免重复读
    #事务A
    commit;
    start transaction;
    update student set name = 'cc' where id = 1;
    commit;
    #事务B
    commit;
    set session transaction isolation level  repeatable read;
    start transaction;
    select * from student where id = 1;

    3、幻读

    #避免幻读
    #事务A
    commit;
    set session transaction isolation level serializable;
    start transaction; 
    select * from student where id =1;
    select * from student where id =1;
    
    #事务B
    commit;
    start transaction;
    insert into student values(12345,'mdm',110);
    commit
    欢迎关注我的公众号:小秋的博客 CSDN博客:https://blog.csdn.net/xiaoqiu_cr github:https://github.com/crr121 联系邮箱:rongchen633@gmail.com 有什么问题可以给我留言噢~
  • 相关阅读:
    Java IO/NIO
    LeetCode—— 两两交换链表中的节点
    LeetCode——合并K个排序链表
    LeetCode第201场周赛
    LeetCode第202场周赛
    LeetCode215. 数组中的第K个最大元素
    LeetCode213. 打家劫舍 II
    LeetCode212. 单词搜索 II
    LeetCode211. 添加与搜索单词
    LeetCode210. 课程表 II
  • 原文地址:https://www.cnblogs.com/flyingcr/p/10326906.html
Copyright © 2011-2022 走看看