### 问题 在JAVA程序中查询`mysql`数据库带有`tinyint(1)`的字段的数据会被转换成`boolean`类型。 ### 原因 `mysql`中`jdbc`默认情况会把`tinyint(1)`当作`boolean`类型。 Table 6.2 MySQL Types and Return Values for ResultSetMetaData.GetColumnTypeName()and ResultSetMetaData.GetColumnClassName() | MySQL Type Name | Return value of GetColumnClassName | Return value of GetColumnClassName| |-----------------|-------------------------|------------------------| |TINYINT|TINYINT|java.lang.Boolean if the configuration property tinyInt1isBit is set to true (the default) and the storage size is 1, or java.lang.Integer if not.| |BOOL, BOOLEAN|TINYINT|See TINYINT, above as these are aliases for TINYINT(1), currently.| 翻译: 如果tinyInt1isBit =true(默认),且tinyInt存储长度为1 ,则转为java.lang.Boolean 。 否则转为java.lang.Integer。 资料链接 [https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html) ### 解决办法 jdbc链接url上面加上`tinyInt1isBit=false`参数 例如: jdbc:mysql://:/?tinyInt1isBit=false