pstmt.setString(1,r.getRid());
pstmt.setString(2,r.getPid());
pstmt.setString(3,r.getCname());
pstmt.setString(4,r.getRname());
pstmt.setString(5,r.getDescription());
其中数据库中,pid和cname是外键,我这么写就报错Cannot add or update a child row: a foreign key constraint fails (`teammanagement`.`requirement`, CONSTRAINT `require_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `project` (`Projectid`))
但是如果我改成pstmt.setString(1,r.getRid());
pstmt.setString(2,"1");//pid对应的别的表中有“1”
pstmt.setString(3,"微软");//cname对应的别的表中有"微软"
pstmt.setString(4,r.getRname());
pstmt.setString(5,r.getDescription());
就成功了,为什么?
å¤å¶ç²è´´æ²¡ä»ä¹ææç
ridæ¯ä¸»é®ï¼æ并没æç¯è¿ç§ä½çº§é误