亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

幫忙查找一下錯誤

??? //修改功能
public void updateGodess(Goddess g) throws Exception{
?? ?Connection conn =DBUtil.getConnection();
??? String sql =""
?? ??? ??? ?+ " update imooc_goddess "+
?? ??? ??? ??? ??? ?" (user_name=?,sex=?,age=?,birthday=?,email=?,mobile=?, "
?? ??? ??? ??? ??? ?+" update_user=?,update_date=current_date(),isdel=?) "
?? ??? ??? ??? ??? ?+" where id =? ";
??? PreparedStatement ptmp =? conn.prepareStatement(sql);
??? ptmp.setString(1, g.getUser_name());
??? ptmp.setInt(2,g.getSex());
??? ptmp.setInt(3, g.getAge());
??? ptmp.setDate(4, new Date(g.getBirthday().getTime()));
??? ptmp.setString(5, g.getEmail());
??? ptmp.setString(6, g.getMobile());
??? ptmp.setString(7, g.getUpdate_user());
??? ptmp.setInt(8, g.getIsdel());
??? ptmp.setInt(9, g.getId());
????? ?
??? ptmp.execute();
}

測試代碼

Goddess g1 = new Goddess();
?? ?g1.setUser_name("小月");
?? ?g1.setAge(22);
?? ?g1.setSex(1);
?? ?g1.setBirthday(new Date());
?? ?g1.setEmail("[email protected]");
?? ?g1.setMobile("1234388888");
?? ?g1.setUpdate_user("ADMIN");
?? ?g1.setIsdel(1);
?? ?g1.setId(3);
?? ?//g.addGoddess(g1);
?? ?g.updateGodess(g1);

拋出異常

Exception in thread "main" 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 '(user_name='小月',sex=1,age=22,birthday='2016-07-05',email='[email protected]',mo' at line 1
?? ?at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

正在回答

2 回答

+" update_user=?,update_date=current_date(),isdel=?) "你這句多了個)

0 回復 有任何疑惑可以回復我~
#1

EKKOY

isdel=?這個后邊的)
2017-03-06 回復 有任何疑惑可以回復我~

你的SQL語句那里寫錯了,換成下面這樣 ?update 表名 ?set 字段1="", 字段2="" ? ? where ?成立的條件

String?sql=""+
		??????"?update?imooc_goddess"+
		??????"?set?user_name=?,sex=?,age=?,birthday=?,email=?,mobile=?,"+
		??????"?update_user=?,update_date=current_date(),isdel=?"+
		??????"?where?id?=?";


1 回復 有任何疑惑可以回復我~
#1

連宏偉HW

樓上正解
2016-07-06 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

幫忙查找一下錯誤

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號