Oracle8i JDBC Developer's Guide and Reference
Release 3 (8.1.7)

Part Number A83724-01

Library

Solution Area

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Valid SQL-JDBC Datatype Mappings

Table 3-2 in Chapter 3 describes the default mappings between Java classes and SQL datatypes supported by the Oracle JDBC drivers. Compare the contents of the JDBC Datatypes, Standard Java Types and SQL Datatypes columns in Table 3-2 with the contents of Table 21-1 below.

Table 21-1 lists all the possible Java types to which a given SQL datatype can be validly mapped. The Oracle JDBC drivers will support these "non-default" mappings. For example, to materialize SQL CHAR data in an oracle.sql.CHAR object use the getCHAR() method. To materialize it as a java.math.BigDecimal object, use the getBigDecimal() method.

Table 21-1 Valid SQL Datatype-Java Class Mappings
These SQL datatypes:   Can be materialized as these Java types:  

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  

DATE  

oracle.sql.DATE  

 

java.sql.Date  

 

java.sql.Time  

 

java.sql.Timestamp  

 

java.lang.String  

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  

 

byte, short, int, long, float, double  

RAW, LONG RAW  

oracle.sql.RAW  

 

byte[]  

ROWID  

oracle.sql.CHAR  

 

oracle.sql.ROWID  

 

java.lang.String  

BFILE  

oracle.sql.BFILE  

BLOB  

oracle.sql.BLOB  

 

java.sql.Blob (oracle.jdbc2.Blob under JDK 1.1.x)  

CLOB  

oracle.sql.CLOB  

 

java.sql.Clob (oracle.jdbc2.Clob under JDK 1.1.x)  

OBJECT  

oracle.sql.STRUCT  

 

java.sql.Struct (oracle.jdbc2.Struct under JDK 1.1.x)  

 

oracle.sql.CustomDatum  

 

oracle.sql.SqlData  

REF  

oracle.sql.REF  

 

java.sql.Ref (oracle.jdbc2.Ref under JDK 1.1.x)  

TABLE (nested), VARRAY  

oracle.sql.ARRAY  

 

java.sql.Array (oracle.jdbc2.Array under JDK 1.1.x)  

any of the above SQL types  

oracle.sql.CustomDatum or oracle.sql.Datum  


Notes:

  • The type UROWID is not supported.

  • The oracle.sql.Datum class is abstract. The value passed to a parameter of type oracle.sql.Datum must be of the Java type corresponding to the underlying SQL type. Likewise, the value returned by a method with return type oracle.sql.Datum must be of the Java type corresponding to the underlying SQL type.

  • The mappings to oracle.sql classes are optimal if no conversion from SQL format to Java format is necessary.

 



Go to previous page
Go to beginning of chapter
Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Solution Area

Contents

Index