利用Mysql进行update时,出现You have an error in your SQL syntax check the manual that corresponds to your My

原创 2012年04月12日 09:45:17

 总是出现You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax ...... at line 1错误。

代码如下:

   ps = conn.prepareStatement("update admin set aid = ?,username = ?,password = ?,password2 = ?"
     + "where aid like ? ");
   ps.setInt(1,admin.getAid());
   ps.setString(2, admin.getUsername());
   ps.setString(3, admin.getPassword());
   ps.setString(4, admin.getPassword2());
   ps.setInt(5, aid);

这段代码没有什么大问题,就是在update的语句中少了个空格!!!

在关键字where后面少了个空格,导致where和参数password2的值连在了一起,出现语法错误。

正确的代码是:
 ps = conn.prepareStatement("update admin set aid = ?,username = ?,password = ?,password2 = ?"
     + " where aid like ? ");

相关文章推荐

MySql建表时出错ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that correspond

在看黑马javaEE32期教程的时候,跳过前面前端的教程。直接看数据库相关,拿起了PPT上面的笔记先建了个数据库。建表的时候,出现了: ERROR 1064 (42000): You have an ...

Hibernate操作MySQL使用reserved word引发错误: “You have an error in your SQL syntax; check the manual that co

今天利用Hibernate4.0上往MySQL 5数据库插入一个Entity时,一直出现以下的错误:   You have an error in your SQL syntax; check t...

MySQL:check the manual that corresponds to your MySQL server version for the right syntax

今天重新搞了一下JDBC,然后在写代码的时候遇到了一个蛋疼的问题,纠结了很久,抛出的异常如下: 数据库连接成功!conn=com.mysql.jdbc.JDBC4Connection@4acdd9b...

check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?

mysql syntax to use near '?

误用关键字-_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax;

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual t...

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax.....

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You ...

JBPM工作流之出现Could not synchronize database state with session以及You have an error in your SQL syntax;的异

在开始写第一个jbpm4工作流框架的例子时出现了下面的异常:

完美解决 ERROR 1064 (42000): You have an error in your SQL syntax ... near …

在MySQL命令行使用sql语句进行建表时,MySQL 报错,这个问题之前遇到过几次,但是总是会因为疏忽又相遇,今天把这个问题写出来,加深印象吧。sql语句:CREATE TABLE 'lrs_aud...

mybatis报“com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL s”

做项目时mybatis报这个错 ### The error occurred while setting parameters ### Cause: com.mysql.jdbc.exceptions...

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL

1、错误描述 org.hibernate.exception.SQLGrammarException: error executing work at org.hibernate.exception...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:利用Mysql进行update时,出现You have an error in your SQL syntax check the manual that corresponds to your My
举报原因:
原因补充:

(最多只允许输入30个字)