Oracle8i JDBC Developer's Guide and Reference Release 2 (8.1.6) A81354-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". Also refer to "Using JPublisher to Create Custom Object Classes", or to the Oracle8i JPublisher User's Guide.
For a complete sample application using the REF class to access SQL object data, see "Weakly Typed Object References--StudentRef.java".