Type name |
Display Length |
Database Type |
Java type |
JDBC index (INT) |
Description |
|
|
|
|
|
|
Varchar |
L + n |
Varchar |
Java. Lang. String |
12 |
|
Char |
N |
Char |
Java. Lang. String |
1 |
|
Blob |
L + n |
Blob |
Java. Lang. byte [] |
-4 |
|
Text |
65535 |
Varchar |
Java. Lang. String |
-1 |
|
|
|
|
|
|
|
Integer |
4 |
Integer unsigned |
Java. Lang. Long |
4 |
|
Tinyint |
3 |
Tinyint unsigned |
Java. Lang. Integer |
-6 |
|
Smallint |
5 |
Smallint unsigned |
Java. Lang. Integer |
5 |
|
Mediumint |
8 |
Mediumint unsigned |
Java. Lang. Integer |
4 |
|
Bit |
1 |
Bit |
Java. Lang. Boolean |
-7 |
|
Bigint |
20 |
Bigint unsigned |
Java. Math. biginteger |
-5 |
|
Float |
4 + 8 |
Float |
Java. Lang. Float |
7 |
|
Double |
22 |
Double |
Java. Lang. Double |
8 |
|
Decimal |
11 |
Decimal |
Java. Math. bigdecimal |
3 |
|
Boolean |
1 |
Same as tinyint |
|
|
|
|
|
|
|
|
|
ID |
11 |
PK (integer unsigned) |
Java. Lang. Long |
4 |
|
|
|
|
|
|
|
Date |
10 |
Date |
Java. SQL. Date |
91 |
|
Time |
8 |
Time |
Java. SQL. Time |
92 |
|
Datetime |
19 |
Datetime |
Java. SQL. Timestamp |
93 |
|
Timestamp |
19 |
Timestamp |
Java. SQL. Timestamp |
93 |
|
Year |
4 |
Year |
Java. SQL. Date |
91 |
The preceding table corresponds to the Java data type and MySQL data type.
For bolb, it is generally used to store images in a database. The principle is to compress the images into binary data and then store them in a storage method that corresponds to byte [] arrays in Java.
For the boolen type, in the MySQL database, I personally think it is better to replace the int type, it is not very convenient for bit operations, especially in projects with web page development, it indicates 0/1, the corresponding Java type Integer is better.
Bit (1) (new in MySQL-5.0) |
Bit |
java.lang.Boolean |
Bit (> 1) (new in MySQL-5.0) |
Bit |
byte[] |
Tinyint |
Tinyint |
java.lang.Boolean If the configuration PropertytinyInt1isBit Is settrue (The default) and the storage size is 1, orjava.lang.Integer If not. |
Bool, Boolean |
Tinyint |
See tinyint, above as these are aliases for tinyint (1), currently. |
Smallint [(m)] [unsigned] |
Smallint [unsigned] |
java.lang.Integer (Regardless if unsigned or not) |
Mediumint [(m)] [unsigned] |
Mediumint [unsigned] |
java.lang.Integer, If unsignedjava.lang.Long (C/J 3.1 and earlier), orjava.lang.Integer For C/J 5.0 and later |
Int, integer [(m)] [unsigned] |
Integer [unsigned] |
java.lang.Integer , If unsignedjava.lang.Long |
Bigint [(m)] [unsigned] |
Bigint [unsigned] |
java.lang.Long , If unsignedjava.math.BigInteger |
Float [(m, d)] |
Float |
java.lang.Float |
Double [(m, B)] |
Double |
java.lang.Double |
Decimal [(M [, d])] |
Decimal |
java.math.BigDecimal |
Date |
Date |
java.sql.Date |
Datetime |
Datetime |
java.sql.Timestamp |
Timestamp [(m)] |
Timestamp |
java.sql.Timestamp |
Time |
Time |
java.sql.Time |
Year [(2 | 4)] |
Year |
IfyearIsDateType Configuration property is set to false, then the returned object type isjava.sql.Short . If set to true (the default) then an object of Typejava.sql.Date (With the date set to January 1st, at midnight ). |
Char (m) |
Char |
java.lang.String (Unless the character set for the column is binary, thenbyte[] Is returned. |
Varchar (m) [binary] |
Varchar |
java.lang.String (Unless the character set for the column is binary, thenbyte[] Is returned. |
Binary (m) |
Binary |
byte[] |
Varbinary (m) |
Varbinary |
byte[] |
Tinyblob |
Tinyblob |
byte[] |
Tinytext |
Varchar |
java.lang.String |
Blob |
Blob |
byte[] |
Text |
Varchar |
java.lang.String |
Mediumblob |
Mediumblob |
byte[] |
Mediumtext |
Varchar |
java.lang.String |
Longblob |
Longblob |
byte[] |
Longtext |
Varchar |
java.lang.String |
Enum ('value1', 'value2 ',...) |
Char |
java.lang.String |
Set ('value1', 'value2 ',...) |
Char |
java.lang.String |
MySQL official documentation: