简体   繁体   中英

Mysql updating user password

I am trying update password for database using mybatis:

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

However, got following exception:

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

I have specified the user id I want to update. Why is it saying "id cannot be null"?

Can someone tell me what I did do wrong?

Remove in the query: id = #{new_id} .

So, the query will be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM