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 true was set to (the default) and the storage size was 1, or java.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 for java.lang.Integer 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 a 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 was BINARY, then is byte[] returned.) |
VARCHAR (M) [BINARY] |
VARCHAR |
java.lang.String (unless the character set for 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 Official documentation:
Http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type-conversions.html
List of Java data types and MySQL data types