问题遇到的现象和发生背景
在JDBC的使用里,我的数据需要更新,确不成功
问题相关代码,请勿粘贴截图
public static void changeOtherAccount() {
ResultSet rs;
PreparedStatement preSql;
Connection con3=new DBconn().getConn();
String sql="update user set name=?,password=? where account=?";
try {
String account=ChangeAccountMessage.accounttext.getText();
String name=ChangeAccountMessage.nametext.getText();
String password=new String(ChangeAccountMessage.passwordtext.getPassword());
preSql=con3.prepareStatement(sql);
preSql.setString(1,name);
preSql.setString(2,password);
preSql.setString(3,account);
boolean ok=preSql.execute(sql);
System.out.println(ok);
} catch (SQLException e) {
System.out.println(e);
}
}
运行结果及报错内容
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,password=? where account=?' at line 1
我的解答思路和尝试过的方法
暂时没有
我想要达到的结果
数据更新成功