SQL and Java Data Type Correspondences

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

Note: Java object types, including arrays, cannot be directly equated to SQL types. To pass objects or arrays to SQL, first convert it to a structure that is SQL compatible. To place SQL information into a Java object will require taking the returned SQL information and converting it (e.g., to populate an array, use a string of values as the item that SQL returns; parse the string to place each value into a cell of the array).

Written by Norman Jacobson, adapting a chart by Chen Li, November 2007.