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.

In the previous example, the application had to perform the following steps inorder to use custom mapping to insert and/or update a database instance:1. Acquire a custom mapped instance (either existing object for update, orusing the constructor that takes the Connection as a parameter for insert).2. Modify the attributes of the custom mapped class.3. Invoke the writeSQL method passing the custom mapped instance as anargument. (This is possible since the custom mapped instance is a subclassof ordbObject, and ordbObject implements the SQLInput and SQLOuputinterfaces.)Writing your own custom mapping classesAlthough the ddltojava utility is the easiest way to generate java classes foruse with custom mapping, you can write your own custom java classes.Custom java classes used for mapping to <strong>Cincom</strong> ORDB classes must:♦♦Implement the SQLData interfaceExtend the ordbjava.jdbc.ordbObject classUnderstanding the SQLData interfaceThe SQLData interface defines methods that translate between SQL and Javafor <strong>Cincom</strong> ORDB database objects.If you create a custom Java class that implements SQLData, you must provide areadSQL() method and writeSQL() method as defined by the SQLData interface.The <strong>JDBC</strong> driver calls your readSQL() method to read a stream of data valuesfrom the database and populate an instance of your custom Java class.Typically, the driver would use this method as part of an ResultSet.getObject()call.The <strong>Cincom</strong> ORDB <strong>JDBC</strong> Driver never invokes the writeSQL() method,but application developers can invoke the writeSQL() method to insertand/or update instances in the database.Understanding the SQLInput and SQLOutput interfaces. The class,ordbObject class of the <strong>Cincom</strong> ORDB <strong>JDBC</strong> driver, implements the SQLInputand SQLOutput interfaces. It is not necessary to implement the SQLOutput orSQLInput objects. The <strong>JDBC</strong> drivers will do this for you.<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 58Chapter: 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!