Mapping of Java and MySQL data types

By xngo on February 27, 2019

Here are the mapping of data types between MySQL and Java.

MySQL           | Java
----------------|---------------------
CHAR            | String
VARCHAR         | String
LONGVARCHAR     | String
NUMERIC         | java.math.BigDecimal
DECIMAL         | java.math.BigDecimal
BIT             | boolean
TINYINT         | byte
SMALLINT        | short
INTEGER         | int
BIGINT          | long
REAL            | float
FLOAT           | double
DOUBLE          | double
BINARY          | byte []
VARBINARY       | byte []
LONGVARBINARY   | byte []
DATE            | java.sql.Date
TIME            | java.sql.Time
TIMESTAMP       | java.sql.Tiimestamp

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.