HomeOracle Page 5 - Extending PL/SQL with Java Libraries, concluded
Mapping Oracle Types - Oracle
If you are looking for a way to extend stored programs with Java, look no further. This article, the second of two parts, is excerpted from chapter five of Expert Oracle PL/SQL, written by Ron Hardman and Michael McLaughlin (McGraw-Hill/Osborne, 2005; ISBN: 0072261943).
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:
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.