我明白了
"MySQLSyntaxErrorExcetpion You have an error in your SQL syntax."我正在关注一个在线教程,我看不出我的代码和我所遵循的代码有什么不同。有谁能指出我哪里出错了吗?
如果需要更多信息,请告诉我。

btn_update.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
try{
theQuery("update users set fname = '" + firstNameField.getText() + "', lname = '" + lastNameField.getText() +"', age=" + ageField.getText() + "where id = " + idField.getText());
}
catch(Exception ex)
{
System.out.println(ex);
}
}
});发布于 2017-01-07 04:53:50
因为这里没有空格:
age=" + ageField.getText() + "where id = " + idField.getText());您需要将其更改为
age= " + ageField.getText() + " where id = " + idField.getText());我建议使用PreparedStatement而不是原生方法
发布于 2017-01-07 04:52:38
在“where id =”前添加一个空格。这应该是可行的
发布于 2017-01-07 04:56:54
使用toString()函数将值转换为字符串,然后将其传递给查询,如下所示:
firstNameField.getText().toString()https://stackoverflow.com/questions/41514078
复制相似问题