weixin_40694508
小虾米闯江湖
2019-04-24 15:33

java中执行delete,insert被重复执行

  • java

得到了一条数据,我现在正常的操作是要先删后增,正常的情况下会执行delete然后insert操作,但是偶尔会delete,delete,insert,insert这样执行条重复的操作,最后导致insert了条重复的,这是偶尔发生的,一条天概4000条数据会有那么2条左右有这种情况,不是前端提交了2次这种情况,问题和这位大哥的一样https://bbs.csdn.net/topics/360209410?list=lz,有遇到过的大哥给个思路

//删除应缴信息
                                        sql = "delete t_jj_sfxx where lsh=  '"+map.get("lsh").toString()+kscs+"' and  xmbm=  '"+maps.get("ffsxmbm")+"' and  clbz='F' ";
                                        jdbcDao.execute(sql);

                                        BigDecimal xmgs_sum = new BigDecimal(xmgs[b]); 
                                        BigDecimal xmje_sum = new BigDecimal(xmje[b]);  
                                        BigDecimal hj_sum = xmgs_sum.multiply(xmje_sum);  
                                        logger.info("获取项目信息---项目数量:"+xmgs_sum+"项目金额:"+xmje_sum+"总金额:"+hj_sum);

                                        sql ="insert into t_jj_sfxx(fid,ysje,hpzl,hphm,sfzh,sjly,lsh,xm,wbywdmsm,ywdwbh,xmbm," +
                                              " xmgs,xmje,clbz,clsj,userid,sflx,jkfs,jkid,kskm,jjxmbm,ywlx,ywyy,czlx,fdwwm,kscs)values  ('"+fids+"','"+xmje[b]+"',''" +
                                                " ,'','"+map.get("zmhm").toString()+"','"+map.get("ywlx").toString()+"'," +
                                                "'"+map.get("lsh").toString()+kscs+"','"+map.get("xm").toString()+"','"+map.get("sfmc").toString()+"'," +
                                                "'"+map.get("glbm").toString()+"','"+maps.get("ffsxmbm")+"',   '"+xmgs[b]+"'," +
                                                " '"+hj_sum+"','F',TO_CHAR(SYSDATE,'yyyy-mm-dd'),'"+user.getUserid()+"','"+inmap.get("sflx")+"','"+user.getJkfs()+"','"+inmap.get("ywlx")+"','"+kskm+"','"+str[b]+"','"+map.get("ywlx").toString()+"','"+map.get("ywyy").toString()+"','"+user.getCzlx()+"','"+user.getDwbm()+"','"+kscs+"')";

                                        jdbcDao.execute(sql);

就是这段代码,大部分情况是delete后insert,但有极少数发生delete delete insert insert,就是那个删除连续运行2次后,插入跟着连续运行了2次

异常日志:图片说明

正常日志:图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答