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.

Inserting, deleting, and updating with custom mappingCustom mapped java class methods allow the application developer to insert,delete, and update instances of the database without using SQL.The following sample code uses custom mapping to insert a new seashoreobject, delete an existing seashore instance, and update a resort object toreference the new seashore.This sample code may be found in the%ORDB%\demo\jdbc\samples\customMappingSample2.java file:These samples assume that the default type map defines all the custom mapsrequired.//// This sample program demonstrates the use of custom mapping//package demo.jdbc.samples;import java.sql.*;import java.math.*;import java.io.*;import ordbjava.jdbc.*;import java.util.HashMap;//import for custom mappingclass customMappingSample2 {public static void main (String args []) throws SQLException{// Connect to the demodb database without autocommit enabled.Connection conn = demodbHelper.makeConnection (false);try{// add type maps for custom mapping.conn.getTypeMap().put("seashore",Class.forName("demo.jdbc.samples.jseashore"));conn.getTypeMap().put("resort",Class.forName("demo.jdbc.samples.jresort"));} catch(ClassNotFoundException e){System.out.println("***Caught SQLException: " + e.getMessage());<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 55Chapter: 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!