Collection Contents Index Data type conversions Year 2000 compliance pdf/chap7.pdf

Reference Manual
   CHAPTER 7. SQL Data Types     

Java / SQL data type conversion


When a Java class field or method is invoked within a SQL statement, a Java data type is returned by the Java object. This must be converted into a SQL data type for use within the SQL statement, for example in comparisons.

Similarly, when a SQL statement is included in a JDBC class, it provides data of SQL data types, which must be converted to Java data types.

Java to SQL and SQL to Java data type conversions are carried out according to the JDBC standard. The conversions are described in the following tables.

Top of page  Java to-SQL-data type conversion

Java type

SQL type

String

CHAR

String

VARCHAR

String

TEXT

java.math.BigDecimal

NUMERIC

Java.math.BigDecimal

MONEY

Java.math.BigDecimal

SMALLMONEY

Boolean

BIT

Byte

TINYINT

short

SMALLINT

int

INTEGER

long

INTEGER

float

REAL

double

DOUBLE

byte[ ]

VARBINARY

Byte[ ]

IMAGE

java.sql.Date

DATE

java.sql.Time

TIME

java.sql.Timestamp

TIMESTAMP

java.lang.Double

DOUBLE

java.lang.Float

REAL

java.lang.Integer

INTEGER

java.lang.Long

INTEGER

Top of page  SQL-to-Java data type conversion

SQL type

Java type

CHAR

String

VARCHAR

String

TEXT

String

NUMERIC

java.math.BigDecimal

DECIMAL

java.math.BigDecimal

MONEY

java.math.BigDecimal

SMALLMONEY

Java.math.BigDecimal

BIT

boolean

TINYINT

byte

SMALLINT

short

INTEGER

int

BIGINT

long

REAL

float

FLOAT

double

DOUBLE

double

BINARY

byte[ ]

VARBINARY

byte[ ]

LONG VARBINARY

byte[ ]

IMAGE

Byte[ ]

DATE

java.sql.Date

TIME

java.sql.Time

TIMESTAMP

java.sql.Timestamp

Top of page  


Collection Contents Index Data type conversions Year 2000 compliance pdf/chap7.pdf