Correspondence between MySQL, JdbcType and JavaType

Correspondence between MySQL, JdbcType and JavaType

Common data type mapping table

MySQL JDBCType JavaType Remarks
char CHAR String Fixed-length character
varchar VARCHAR String Variable length character
tinyint TINYINT byte 1 byte
smallint SMALLINT short 2 bytes
int INTEGER int 4 bytes
float FLOAT float 4 bytes
bigint BIGINT long 8 bytes
double DOUBLE double 8 bytes
bit BOOLEAN boolean Boolean type

Date time and large object mapping table

MySQL JDBCType JavaType Remarks
date DATE java.util.Date、java.sql.Date YYYY-MM-DD
time TIME java.util.Date、java.sql.Date HH:MM:SS
timestamp TIMESTAMP java.util.Date、java.sql.Date YYYY-MM-DD HH:MM:SS (not strictly in this format, rather messy)
text VARCHAR String Text type (2^16-1 byte)
longtext LONGVARCHAR String Long text type (2^32-1 byte)

note:

To convert datetimedata of a type in MySQL into data in a yyyy-MM-dd HH:mm:ssformat, you need to use MySQL library functions. DATE_FORMAT()
You can refer to the following:
https://blog.csdn.net/qq_27198345/article/details/112605258

Guess you like

Origin blog.csdn.net/qq_27198345/article/details/112606155