gpt4 book ai didi

java - insert 语句参数太少

转载 作者:行者123 更新时间:2023-12-01 14:17:16 25 4
gpt4 key购买 nike

您好,我正在尝试插入语句,但不断收到以下错误:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.

这是我的代码:

 try {

Statement stmt = con.createStatement();

String mySqlStatement = "INSERT INTO EntrantDetails (ID, Name, Surname, Gender, DOB ChipNum) VALUES (" + details.getIDNum()+ "," + details.getName() + "," + details.getSurname() + "," + details.getGender() + "," + details.getDOB() + "," + details.getChipNum() + ")";
stmt.executeUpdate(mySqlStatement);
}

catch (Exception ex)
{
ex.printStackTrace();
}

最佳答案

您在 DOB 和 ChipNum 之间缺少一个逗号。稍微注意一下你所写的内容。

关于java - insert 语句参数太少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18016362/

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