Extending PL/SQL with Java Libraries, concluded - Mapping Oracle Types (
Page 5 of 5 )
Oracle maps all native types and User Defined Types (UDTs) to Java types. When you use SQLData you map individual components and structures. The following table notes how Oracle types map to Java types:
|
SQL Data Types |
Java Class Data Types |
|
CHAR |
oracle.sql.CHAR |
|
LONG |
java.lang.String |
|
VARCHAR2 |
java.lang.Byte |
|
|
java.lang.Short |
|
|
java.lang.Integer |
|
|
java.lang.Long |
|
|
java.lang.Float |
|
|
java.lang.Double |
|
|
java.lang.BigDecimal |
|
|
java.sql.Date |
|
|
java.sql.Time |
|
|
java.sql.Timestamp |
|
|
byte |
|
|
short |
|
|
int |
|
|
long |
|
|
float |
|
|
double |
|
DATE |
oracle.sql.DATE java.lang.String java.sql.Date java.sql.Time java.sql.Timestamp |
|
NUMBER |
oracle.sql.NUMBER java.lang.Byte java.lang.Short java.lang.Integer java.lang.Long java.lang.Float java.lang.Double java.lang.BigDecimal byte short |
|
|
int |
|
|
long float |
|
|
double |
|
OPAQUE |
oracle.sql.OPAQUE |
|
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 oracle.jdbc.Blob (JDK 1.1.x |
|
CLOB NCLOB |
oracle.sql.CLOB oracle.jdbc.Clob (JDK 1.1.x |
|
OBJECT Object types |
oracle.sql.STRUCT java.sql.Struct (JDK 1.1.x) |
|
|
java.sql.SQLData |
|
|
oracle.sql.ORAData |
|
REF |
oracle.sql.REF |
|
Reference types |
java.sql.Ref (JDK 1.1.x) |
|
|
oracle.sql.ORAData |
|
TABLE |
oracle.sql.ARRAY |
|
VARRAY |
java.sql.Array (JDK 1.1.x) |
|
Nested table and types |
oracle.sql.ORAData |
|
VARRAY types |
|
|
Any of the preceding |
oracle.sql.CustomDatum |
|
SQL types |
oracle.sql.Datum |
Native types and UDTs can be used and managed by the SQLData conventions covered in the chapter. The Oracle JPublisher tool enables you to develop SQLData stubs and programs to use your UDTs.
Summary
You should now have an understanding of how to implement and troubleshoot server-side or internal Java class libraries. With these skills, you can build robust solutions in Java, affording you a certain simplicity over using PL/SQL.