Oracle8i JDBC Developer's Guide and Reference
Release 2 (8.1.6)

A81354-01

Library

Product

Contents

Index

Prev  Chap Top Next

Accessing and Updating Object Values through an Object Reference

You can use the REF object setValue() method to update the value of an object in the database through an object reference. To do this, you must first retrieve the reference to the database object and create a Java object (if one does not already exist) that corresponds to the database object.

For example, you can use the code in the section "Retrieving and Passing an Object Reference" to retrieve the reference to a database ADDRESS object:

ResultSet rs = stmt.executeQuery("SELECT col3 FROM PEOPLE"); 
if (rs.next())
{
   REF ref = rs.getREF(1);
   Address a = (Address)ref.getValue();
}

Then, you can create a Java Address object (this example omits the content for the constructor of the Address class) that corresponds to the database ADDRESS object. Use the setValue() method of the REF class to set the value of the database object:

Address addr = new Address(...);
ref.setValue(addr);

Here, the setValue() method updates the database ADDRESS object immediately.




Prev

Top

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index