Type name |
Display length |
Database type |
Java type |
JDBC Type index (int) |
Describe |
|
|
|
|
|
|
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 |
With 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 above is the Java data type and MySQL data type corresponding table.
For Bolb, generally used for the database storage of pictures, the principle is to make the picture into binary, and then do a storage method, in Java corresponding to the byte[] array.
For the Boolen type, in the MySQL database, the individual think that using the int type is better, the bit operation is not very convenient, especially in the project with Web page development, represents 0/1, corresponding to the Java type of 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 property tinyint1isbit is set To true (the default) and the storage size is 1, orjava.lang.integer if not. |
BOOL, BOOLEAN |
TINYINT |
See TINYINT, above as these is 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 unsigned java.lang.long (c/j 3.1 and earlier), Or java.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 |
if yearisdatetype configuration property was set to false and then the returned object type Is java.sql.short . If set to True (the default) then an object of Type java.sql.date (with the Date set to January 1st, at midnight). |
char (M) |
char |
Java.lang.String (unless the character set for the column Isbinary, Then byte[ ] is returned. |
VARCHAR (M) [BINARY] |
VARCHAR |
java.lang.String (unless the character setfor the column was BINARY, then is byte[] 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 data type and Java data type corresponding list