2013-11-22 39 views
1

我使用的MyBatis试图更新密码数据库:Mysql的更新用户密码

update person 
    set name = #{name}, 
     address = #{address}, 
     phoneNumber = #{phoneNumber}, 
     balance = #{balance}, 
     password = #{password}, 
     id = #{new_id} 
where id = #{id} 

但是,有以下情况除外:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null 
### The error may involve com.lsp.mybatis.PersonMapper.update-Inline 
### The error occurred while setting parameters 
### SQL: update person set name = ?, address = ?, phoneNumber = ?    ,balance = ?, password = ?, id = ? where id = ? 
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null 

我已指定用户ID我想更新。为什么说“ID不能为空”?

有人能告诉我我做错了什么吗?

+0

是否要更新'ID'或'password'? – Smit

回答

2

删除查询:id = #{new_id}

因此,查询将是:

update person 
    set name = #{name}, 
     address = #{address}, 
     phoneNumber = #{phoneNumber}, 
     balance = #{balance}, 
     password = #{password} 
where id = #{id}