DataIntegrityViolationException异常:java利用mymatis连接数据库异常 电玩女神 2022-05-15 00:23 604阅读 0赞 异常出现的信息 DataIntegrityViolationException: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`data`.`orderdetail`, CONSTRAINT `FK_orderdetail_2` FOREIGN KEY (`items_id`) REFERENCES `items` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ### The error may involve cn.itcast.ssm.mapper.ItemsMapper.deleteItemById-Inline ### The error occurred while setting parameters ### SQL: delete from items where id=? ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`data`.`orderdetail`, CONSTRAINT `FK_orderdetail_2` FOREIGN KEY (`items_id`) REFERENCES `items` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ; SQL []; Cannot delete or update a parent row: a foreign key constraint fails (`data`.`orderdetail`, CONSTRAINT `FK_orderdetail_2` FOREIGN KEY (`items_id`) REFERENCES `items` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`data`.`orderdetail`, CONSTRAINT `FK_orderdetail_2` FOREIGN KEY (`items_id`) REFERENCES `items` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:927) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) -------------------- 出现这种问题是数据库表与别的表有想连接关系,如果别的表没有用,将别的表删除就好了,就可以操作这个表!
还没有评论,来说两句吧...