錯誤求解答
總是提示我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("[email protected]");
? ? ? ? g1.setMobile("54354435151");
? ? ??
? ? ??
? ? ? ? g1.setUpdate_user("dlsd");
? ? ? ? g1.setIsdel(1);
? ? ? ??
? ? ? ? g1.setId(1);
? ? ? ??
? ? ? ?g.updateGoddess(g1);
2016-11-30
isdel=?) ?多了一個括號