Supported SQL data types in Java

 < Day Day Up > 



Table 9-6 shows the Java equivalent of each SQL data type, based on the JDBC specification for data type mappings. The JDBC driver converts the data exchanged between the application and the database using the following mapping schema. Use these mappings in your Java applications and your PARAMETER STYLE JAVA procedures and UDFs.

Table 9-6: SQL data types mapped to Java declarations
 

SQL data type sqltype

Java type

sqllen

Description

integer

SMALLINT (500 or 501)

short

2

16-bit, signed integer

 

INTEGER (496 or 497)

int

4

32-bit, signed integer

 

BIGINT 1 (492 or 493)

long

8

64-bit, signed integer

floating point

REAL (480 or 481)

float

 

Single precision floating point

 

DOUBLE (480 or 481)

double

4

Single precision floating point

 

DOUBLE (480 or 481)

double

8

Double precision floating point

decimal

DECIMAL(p,s) (484 or 485)

java.math. BigDecimal

n/2

Packed decimal

date / time

DATE (384 or 385)

java.sql.Date

10

10-byte character string

 

TIME (388 or 389)

java.sql.Time

8

8-byte character string

 

TIMESTAMP (392 or 393)

java.sql. Timestamp

26

26-byte character string

character

CHAR (452 or 453)

java.lang.String

n

Fixed-length character string of length n where n is from 1 to 254

 

CHAR FOR BIT DATA

byte[]

 

Fixed-length character string of length n where n is from 1 to 254

 

VARCHAR (448 or 449)

java.lang.String

n

Variable-length character string, n <= 32672

 

VARCHAR FOR BIT DATA

byte[]

 

Variable-length character string

 

LONG VARCHAR (456 or 457)

java.lang.String

n

Long variable-length character string, n <= 32672

 

CLOB(n) (408 or 409)

java.lang.Clo b

n

Large object variable-length character string

binary

BLOB(n) (404 or 405)

ava.lang.Blob

n

Large object variable-length binary string

doublebyte

GRAPHIC(n) (468 or 469)

java.lang.String

n

Fixed-length double-byte character string

 

VARGRAPHIC(n) (464 or 465)

java.lang.String

n*2+4

Non-null-terminated varying double-byte character string with 2-byte string length indicator

 

LONG VARGRAPHIC(n) (472 or 473)

java.lang.String

n

Non-null-terminated varying double-byte character string with 2-byte string length indicator

 

DBCLOB(n) (412 or 413)

java.lang.Clob

 

Large object variable-length double-byte character string

Note 

For Java applications connected from a DB2 UDB Version 8.1 client to a DB2 UDB Version 7.x server, when the getObject() method is used to retrieve a BIGINT value, a java.math.BigDecimal object is returned.



 < Day Day Up > 



Oracle to DB2 UDB Conversion Guide2003
Oracle to DB2 UDB Conversion Guide2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net