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 有什么问题可以给我留言噢~
  • 相关阅读:
    MkDocs: 构建你自己的知识库
    Vue入门
    Vue UI库
    【入门】PyTorch
    【转载】工业相机的原理与选型
    如果你是狮子,就得学会逼狼去吃草
    【转载】剖析Git的实现机制
    管理学-员工管理
    量化投资
    【汇总】图像格式
  • 原文地址:https://www.cnblogs.com/flyingcr/p/10326906.html
Copyright © 2011-2022 走看看