Oracle8i JDBC Developer's Guide and Reference Release 3 (8.1.7) Part Number A83724-01 |
|
Oracle supports the use of references (pointers) to Oracle database objects. Oracle JDBC provides support for object references as:
IN
or OUT
bind variables
In SQL, an object reference (REF
) is strongly typed. For example, a reference to an EMPLOYEE
object would be defined as an EMPLOYEE REF
, not just a REF
.
When you select an object reference in Oracle JDBC, be aware that you are retrieving only a pointer to an object, not the object itself. You have the choice of materializing the reference as a weakly typed oracle.sql.REF
instance (or a java.sql.Ref
instance for portability), or materializing it as an instance of a custom Java class that you have created in advance, which is strongly typed. Custom Java classes used for object references are referred to as custom reference classes in this manual and must implement the oracle.sql.CustomDatum
interface.
The oracle.sql.REF
class implements the standard java.sql.Ref
interface (oracle.jdbc2.Ref
under JDK 1.1.x).
You can retrieve a REF
instance through a result set or callable statement object, and pass an updated REF
instance back to the database through a prepared statement or callable statement object. The REF
class includes functionality to get and set underlying object attribute values, and get the SQL base type name of the underlying object (for example, EMPLOYEE
).
Custom reference classes include this same functionality, as well as having the advantage of being strongly typed. This can help you find coding errors during compilation that might not otherwise be discovered until runtime.
For more information about custom reference classes, see "Custom Reference Classes with JPublisher".
For a complete sample application using the REF class to access SQL object data, see "Weakly Typed Object References--StudentRef.java".
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|