Java MySQL的JDBC更新错误-错误代码1054
这是密码Java MySQL的JDBC更新错误-错误代码1054,java,mysql,sql,Java,Mysql,Sql,这是密码 PreparedStatement res1 = null; String insertUser = "INSERT INTO users (uid,firstname,lastname,score) VALUES (" + this.getFbUid() + "," + this.getFb
PreparedStatement res1 = null;
String insertUser = "INSERT INTO users (uid,firstname,lastname,score) VALUES (" +
this.getFbUid() + "," +
this.getFbFirstName() + "," +
this.getFbLastName() + ",0)";
System.out.println(insertUser);
try
{
res1 = connection.prepareStatement(insertUser);
res1.executeUpdate();
System.out.println("executed query to db with the message" + res1);
}
catch(SQLException e)
{
System.out.println("setUserInDb: " +e.getMessage());
System.out.println("error num: " +e.getErrorCode());
}`
我得到了错误代码1054:
尝试将行insert插入用户uid、firstname、lastname、分数值123456、Alon、xyz、0时,“字段列表”中的未知列“Alon”
在db中,我有一个表用户,其varchar列为uid、firstname、lastname和score。
我做错了什么?Alon似乎或varchar类型应该在'
使用事先准备好的陈述,而不是像Jigar指出的那样 在表中插入字符串值时,应使用单引号或双引号中的值。
例如“您好”,您好。如何用java修复我的字符串?您没有正确使用它,请务必使用单引号:“您好”。双引号用于引用对象名称。我知道MySQL允许非标准引用,但是如果标准语法也被接受,就没有必要使用它。