简体   繁体   中英

How to update the table value field which type is bit using mybatis in mysql?

I have a table called tbStudent. When I set the sex field using integers, and pass the parameter value in as 1 or 0 , it works just fine. But now,when I try to update the sex field type using bits, and also pass the parameter value in as 1 or 0 , it does not work correctly. I try to pass the parameter value in as true or false ,but it still does not work as intended. How to fix it so that it will work with bits? The error is:

//I only pass in the value 1, why does it say too long?
Data truncation: Data too long for column 'SEX' at row 1;
nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: 
Data too long for column 'SEX' at row 1

尝试将其插入为b'1'或b'0'源: http ://dev.mysql.com/doc/refman/5.0/en/bit-field-literals.html

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