O'Reilly logo

Java Programming with Oracle JDBC by Donald Bales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Types

Whether you move data between two computers, computer systems, or programs written in different programming languages, you’ll need to identify which data types can be moved from one setup to another and how. This problem arises when you retrieve data from an Oracle database in a Java program and store data from a Java program in the database. It’s a function of the JDBC driver to know how to move or convert the data as it moves between your Java program and Oracle, but you as the programmer must know what is possible or, more importantly, legal. Table 10-1 lists the Oracle SQL data types and all their valid Java data type mappings.

Table 10-1. Valid Oracle SQL-to-Java data type mappings

Oracle SQL data type

Valid Java data type mappings

BFILE

oracle.sql.BFILE

BLOB

oracle.sql.BLOB

java.sql.Blob

CHAR, VARCHAR2, LONG

oracle.sql.CHAR

java.lang.String

java.sql.Date

java.sql.Time

java.sql.Timestamp

java.lang.Byte

java.lang.Short

java.lang.Integer

java.lang.Long

java.lang.Float

java.lang.Double

java.math.BigDecimal

byte

short

int

long

float

double

CLOB

oracle.sql.CLOB

java.sql.Clob

DATE

oracle.sql.DATE

java.sql.Date

java.sql.Time

java.sql.Timestamp

java.lang.String

OBJECT

oracle.sql.STRUCT

java.sql.Struct

oracle.sql.CustomDatum

java.sql.SQLData

NUMBER

oracle.sql.NUMBER

java.lang.Byte

java.lang.Short

java.lang.Integer

java.lang.Long

java.lang.Float

java.lang.Double

java.math.BigDecimal ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required