Mysql-Java 数据类型映射
| MySQL Type | Java Type |
| BIT(1) (new in MySQL-5.0) | java.lang.Boolean |
| BIT( > 1) (new in MySQL-5.0) | byte[] |
| 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 | See TINYINT, above as these are aliases for TINYINT(1), currently. |
| SMALLINT[(M)] [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
| MEDIUMINT[(M)] [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
| INT,INTEGER[(M)] [UNSIGNED] | java.lang.Integer, if UNSIGNED java.lang.Long |
| BIGINT[(M)] [UNSIGNED] | java.lang.Long, if UNSIGNED java.math.BigInteger |
| FLOAT[(M,D)] | java.lang.Float |
| DOUBLE[(M,B)] | java.lang.Double |
| DECIMAL[(M[,D])] | java.math.BigDecimal |
| DATE | java.sql.Date |
| DATETIME | java.sql.Timestamp |
| TIMESTAMP[(M)] | java.sql.Timestamp |
| TIME | java.sql.Time |
| YEAR[(2|4)] |
If yearIsDateType configuration property is set to false, then the returned object type is java.sql.Short. If set to true (the default), then the returned object is of type java.sql.Date with the date set to January 1st, at midnight. |
| CHAR(M) |
java.lang.String (unless the character set for the column is BINARY, then byte[] is returned. |
| VARCHAR(M) [BINARY] |
java.lang.String (unless the character set for the column is BINARY, then byte[] is returned. |
| BINARY(M) | byte[] |
| VARBINARY(M) | byte[] |
| TINYBLOB | byte[] |
| TINYTEXT | java.lang.String |
| BLOB | byte[] |
| TEXT | java.lang.String |
| MEDIUMBLOB | byte[] |
| MEDIUMTEXT | java.lang.String |
| LONGBLOB | byte[] |
| LONGTEXT | java.lang.String |
| ENUM('value1','value2',...) | java.lang.String |
| SET('value1','value2',...) | java.lang.String |
本文详细介绍了MySQL数据库中的各种数据类型与Java中的对应数据类型的映射关系,包括数值类型、日期时间类型、字符串类型及二进制类型等。
373

被折叠的 条评论
为什么被折叠?



