使用sql更新语句出现错误

来源:百度知道 编辑:UC知道 时间:2024/06/26 00:49:39
"updata cb_user set userpwd=?,duserpwd=?,name=?,sex=?,department=?,birthday=?,tel=?,email=?,other=? where username = ?
com.mysql.jdbc.exceptions.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 'updata cb_user set userpwd='555',duserpwd='555',name='555',sex='?”·',department=' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882)
at com.daoimpl.UserDaoImpl.ModifyUserInfoByUser

String s="update cb_user set userpwd=?,duserpwd=?,name=?,sex=?,department=?,birthday=?,tel=?,email=?,other=? where username = ?;";

//因为update关键字写成updata,所以无法更新,报错了,以上放到你的程序里就不报错了。

--
//需要指出的是参数个数要够和类型要写对。