Since the Java built-in types such as boolean and int are not subtypes of Object, there is a slightly different mapping from Java Object types to JDBC types for the getObject/setObject methods. Two tables are presented below: the first shows the normal mapping, and the second shows the getObject/setObject method mapping.
The mapping for String will normally be VARCHAR, but will turn into LONGVARCHAR if the given value exceeds the driver's limit on VARCHAR values. The same is true for values of type byte[], VARBINARY, and LONGVARBINARY.
Java Type | JDBC type |
---|---|
String | VARCHAR or LONGVARCHAR |
java.math.BigDecimal | NUMERIC |
boolean | BIT |
byte | TINYINT |
short | SMALLINT |
int | INTEGER |
long | BIGINT |
float | REAL |
double | DOUBLE |
byte[] | VARBINARY or LONGVARBINARY |
java.sql.Date | DATE |
java.sql.Time | TIME |
java.sql.Timestamp | TIMESTAMP |
Java Object type | JDBC type |
---|---|
String | VARCHAR or LONGVARCHAR |
java.math.BigDecimal | NUMERIC |
Boolean | BIT |
Integer | INTEGER |
Long | BIGINT |
Float | REAL |
Double | DOUBLE |
byte[] | VARBINARY or LONGVARBINARY |
java.sql.Date | DATE |
java.sql.Time | TIME |
java.sql.Timestamp | TIMESTAMP |