Launch your tech mastery with us—your coding journey starts now!
Course Content
Advanced Java

The JDBC driver converts the Java data type to the appropriate JDBC type before sending it to the database. It uses a default mapping for most data types. For example, a Java int is converted to an SQL INTEGER. Default mappings were created to provide consistency between drivers.

The following table summarizes the default JDBC data type that the Java data type is converted to when you call the setXXX() method of the PreparedStatement or CallableStatement object or the ResultSet.updateXXX() method.

SQL

JDBC/Java

setXXX

updateXXX

VARCHAR

java.lang.String

setString

updateString

CHAR

java.lang.String

setString

updateString

LONGVARCHAR

java.lang.String

setString

updateString

BIT

boolean

setBoolean

updateBoolean

NUMERIC

java.math.BigDecimal

setBigDecimal

updateBigDecimal

TINYINT

byte

setByte

updateByte

SMALLINT

short

setShort

updateShort

INTEGER

int

setInt

updateInt

BIGINT

long

setLong

updateLong

REAL

float

setFloat

updateFloat

FLOAT

float

setFloat

updateFloat

DOUBLE

double

setDouble

updateDouble

VARBINARY

byte[ ]

setBytes

updateBytes

BINARY

byte[ ]

setBytes

updateBytes

DATE

java.sql.Date

setDate

updateDate

TIME

java.sql.Time

setTime

updateTime

TIMESTAMP

java.sql.Timestamp

setTimestamp

updateTimestamp

CLOB

java.sql.Clob

setClob

updateClob

BLOB

java.sql.Blob

setBlob

updateBlob