Data type Mapping
In this chapter you will learn:
Data type mapping and corresponding methods
JDBC driver converts the Java data type to database back and forth. The following table summarizes the JDBC vs Java data type mapping.
The mapping is used by PreparedStatement
,
CallableStatement
and ResultSet
.
Database | Java | Method |
---|---|---|
VARCHAR | java.lang.String | getString / setString / updateString |
CHAR | java.lang.String | getString / setString / updateString |
LONGVARCHAR | java.lang.String | getString / setString / updateString |
BIT | boolean | getBoolean / setBoolean / updateBoolean |
NUMERIC | java.math.BigDecimal | getBigDecimal / setBigDecimal / updateBigDecimal |
TINYINT | byte | getByte / setByte / updateByte |
SMALLINT | short | getShort / setShort / updateShort |
INTEGER | int | getInt / setInt / updateInt |
BIGINT | long | getLong / setLong / updateLong |
REAL | float | getFloat / setFloat / updateFloat |
FLOAT | float | getFloat / setFloat / updateFloat |
DOUBLE | double | getDouble / setDouble / updateDouble |
VARBINARY | byte[ ] | getBytes / setBytes / updateBytes |
BINARY | byte[ ] | getBytes / setBytes / updateBytes |
DATE | java.sql.Date | getDate / setDate / updateDate |
TIME | java.sql.Time | getTime / setTime / updateTime |
TIMESTAMP | java.sql.Timestamp | getTimestamp / setTimestamp / updateTimestamp |
CLOB | java.sql.Clob | getClob / setClob / updateClob |
BLOB | java.sql.Blob | getBlob / setBlob / updateBlob |
ARRAY | java.sql.Array | getARRAY / setARRAY / updateARRAY |
REF | java.sql.Ref | getRef / setRef / updateRef |
STRUCT | java.sql.Struct | getStruct / setStruct / updateStruct |
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » SQL Data Types