10.07.2015 Views

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

custom mapped class, then.// 5. Invokes the readSQL() method (of the SQLData// interface) on the custom class.// (The SQLData interface must be implemented by a custom// class.)// 6. When readSQL is done, the java instance will be// populated with the attribute data from the database.System.out.println("beach description of resort " +rset.getString(1) + " :" + beach.description);}...Using the ordbObject.getObject methodThe ordbObject class also supports the getObject method. When you call thegetObject method of an instance of ordbObject, the <strong>JDBC</strong> driver willmaterialize the database object referenced by the ordbObject as an instanceof the custom mapped java class. If the type map (either the default, or passedas a parameter) does not contain a mapping for the database class that theordbObject is an instance of, then the getObject method will return theordbObject as a java.sql.Struct (via a cast).The following example assumes that the default type map associates thedatabase class “seashore” with the java class jseashore, and the database class“resort” with the java class jresort:ResultSet rset = stmt.executeQuery ("SELECT resort.IDENTITY resortWHERE beach IS NOT NULL");jresort resort = null;while (rset.next ()) {resort = rset.getObject(1));jseashore seashore = resort.beach.getObject();System.out.println("beach description of resort " +resort.name + " :" + seashore.description);}...<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 51Chapter: 4. <strong>Cincom</strong> ORDB ExtensionsSection: Creating custom Java classes for <strong>Cincom</strong> ORDB objects

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!