Comparison between Java data types and MySql Data Types

Source: Internet
Author: User
Type name display length Database Type JAVA type JDBC Type Index (int) Description VARCHARLNVARCHARjava. lang. String12CHARNCHARjava. lang. String1BLOBLNBLOBjava. lang. byte []-4TEXT65535VARCHARjava. lang. String-1INTEGER4INTEGERUNSIGNEDjava.lang

Type name display length Database Type JAVA type JDBC Type Index (int) Description varchar ln varchar java. lang. string 12 char n char java. lang. string 1 blob ln blob java. lang. byte []-4 TEXT 65535 VARCHAR java. lang. string-1 INTEGER 4 integer unsigned java. lang

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





This table is useful when you design a database or change the database environment for a project.

References: http://www.cnblogs.com/JemBai/archive/2009/08/20/1550683.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.