为了账号安全,请及时绑定邮箱和手机立即绑定

update更新数据是出错

错误提示:

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 '='?°??¤?',sex=1,age=20,birthday='3916-05-12',email='xiaoxia@126.com',mobile='133' at line 1

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

at com.mysql.jdbc.Util.getInstance(Util.java:384)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)

at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1364)

at jdbc_imooc.model.godnessDao.updateGodness(godnessDao.java:65)

at jdbc_imooc.Action.GodnessAction.main(GodnessAction.java:28)

源代码:

public void updateGodness(godness g) throws Exception {

// 获得数据库链接

Connection conn = DBUtil.getConnection();

// 执行insert into

String sql = "" + " insert into imooc_goddness "

+ " (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();

}


正在回答

3 回答

数据库语法错了,还有一个可能就是把你的参数不要填中文就可以了

0 回复 有任何疑惑可以回复我~

看下是不是换行的时候没有加空格

0 回复 有任何疑惑可以回复我~

你这个是数据库语句语法错误,建议将生成的数据库语句打印出来看看哪里错误了

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

update更新数据是出错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信