旗开得胜wds
2016-11-30 10:41
总是提示我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 ') WHERE id = 1' at line 1
但是我反复对着视频看了好几遍,都一样啊
public void updateGoddess(Goddess g) throws Exception{
Connection conn = DBUtil.getConnection();
String sql = " UPDATE imooc_goddess " + " SET user_name=?,sex=?,age=?,birthday=?,email=?,mobile=?," +
" update_user=?,update_date=current_date(),isdel=?) " + " WHERE id = ? ";
PreparedStatement ptmt = conn.prepareStatement(sql);
ptmt.setString(1, g.getUser_name());
ptmt.setInt(2, g.getSex());
ptmt.setInt(3, g.getAge());
ptmt.setDate(4, new Date(g.getBirthday().getTime()));
ptmt.setString(5, g.getEmail());
ptmt.setString(6,g.getMobile());
ptmt.setString(7, g.getUpdate_user());
ptmt.setInt(8, g.getIsdel());
ptmt.setInt(9, g.getId());
ptmt.execute();
}
调用:
public static void main(String[] args) throws Exception {
GoddessDao g = new GoddessDao();
/*
* List<Goddess> gs = g.query();
for (Goddess goddess : gs) {
System.out.println(goddess.getUser_name() + "," + goddess.getAge());
}
*/
Goddess g1 = new Goddess();
g1.setUser_name("黄蓉");
g1.setSex(1);
g1.setAge(20);
g1.setBirthday(new Date());
g1.setEmail("12344870@qq.com");
g1.setMobile("54354435151");
g1.setUpdate_user("dlsd");
g1.setIsdel(1);
g1.setId(1);
g.updateGoddess(g1);
isdel=?) 多了一个括号
JDBC之 “ 对岸的女孩看过来”
99327 学习 · 914 问题
相似问题