gpt4 book ai didi

java - 外键始终保持为空

转载 作者:行者123 更新时间:2023-11-29 04:06:18 25 4
gpt4 key购买 nike

我需要一些帮助来连接我的两个表

这些是“idPatient 是外键”的表 enter image description here

我这样填写表格“tanden”

public void addTandenToDatabase(int id, int fdi, String voorstelling, String toestand) {
String insertSql = "insert into tanden(id, fdi, voorstelling, toestand) values (:idVal, :fdiVal, :voorstellingVal, :toestandVal)";
try (Connection con = sql2o.open()) {
con.setRollbackOnException(false);
con.createQuery(insertSql)
.addParameter("idVal", id)
.addParameter("fdiVal", fdi)
.addParameter("voorstellingVal", voorstelling)
.addParameter("toestandVal", toestand)
.executeUpdate();
}
}

一切都很好地添加,但 idPatient 保持为空

enter image description here

最佳答案

如果要为其设置值,则应在 insert 中包含 idPatient。 '外键'并不意味着它将自动设置值。

关于java - 外键始终保持为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37478754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com