Skip to content

MySQL 字段类型是 tinyint(1) 却只能返回 0 / 1true / false 的原因与解决方法 #47

@troyzhxu

Description

@troyzhxu

原因

这是因为 MySQL 会把 tinyint(1) 自动转为 bit 导致的。

1810e22875f30879e9ac602b9f97a00

参考:https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html

解决方案

只需在 MySQL 连接地址上加一个 tinyInt1isBit=false 参数即可,例如:

spring.datasource.url = jdbc:mysql://xxx/demo?tinyInt1isBit=false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions