gpt4 book ai didi

java - 我有一个基本的 UpdateWhere 语句,该语句在语法上是正确的,但不会更新表

转载 作者:行者123 更新时间:2023-11-29 08:17:53 25 4
gpt4 key购买 nike

这是代码:

@Override public void update(){
Statement stmt = null;
String company = "";
try {
Connect conn = new Connect();
stmt = conn.makeStatement();
// This creates the SQL statement to update an existing student.
System.out.println("Update employee"
+ " Set employeeID = employeeID,"
+ " firstName = firstName,"
+ " lastName = lastName,"
+ " paRating = paRating,"
+ " status = status,"
+ " manager = managerr,"
+ " level = level,"
+ " company = company"
+ " WHERE employeeID = " + get EmployeeID()
+ "Limit 1");

stmt.execute("Update employee"
+ " Set employeeID = employeeID,"
+ " firstName = firstName,"
+ " lastName = lastName,"
+ " paRating = paRating,"
+ " status = status,"
+ " manager = managerr,"
+ " level = level,"
+ " company = company"
+ " WHERE employeeID = " + get EmployeeID()
+ "Limit 1");

stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
System.err.println("Unable to update employee in the database.");
} finally {
}
System.out.println("Employee successfully updated to the database.");
}

我假设我错过了一些我看不到的简单而明显的东西。

最佳答案

此查询不会更新任何内容 - 它只是将大量列设置为其现有值。如果您想将它们更新为其他内容,您最好以某种方式传递这些“其他内容”值。

关于java - 我有一个基本的 UpdateWhere 语句,该语句在语法上是正确的,但不会更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20182026/

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