我需要一些帮助来连接我的两个表
我这样填写表格“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 保持为空
最佳答案
如果要为其设置值,则应在 insert
中包含 idPatient
。 '外键'并不意味着它将自动设置值。
关于java - 外键始终保持为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37478754/