2013-11-22 69 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}