1、今天下午从四点一直修改到7点,接近3个小时,由于自己是初学者,费了不少时间和精力。
2、更新数据为什么会出现上述问题,加问号报错,不加也报错?
3、JDBC:for the right syntax to use near '?where id=?'
String sql = "update userinfo set balance=?"+"where id=?";
PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
ps.setDouble(1, balance);
ps.setInt(2, id);
ps.executeUpdate(sql);
3、错误原因:ps.executeUpdate();//这里面不可加sql,否则会报错
4、关于Statement和PreparedStatement的关系和区别参考:https://blog.youkuaiyun.com/suwu150/article/details/52745055#commentBox