import oracle.pol.jac.*; public class JACProduct { /** * Constructor. */ public JACProduct () { } public static void main(String args[]) { POLConnection pcon=null; try { pcon= POLConnection.getConnection("\\ORAWIN95\\POLDB\\POLITE.odb", POLConnection.CONNECT_READ_WRITE); // find the product class POLClass product_class = POLClass.findClass(pcon, "PRODUCT"); POLGroup product_group = POLGroup.findGroup(pcon, "PRODUCT"); // find all the attribute objects of the product class POLAttr pid_attr = product_class.findAttr("PID"); POLAttr name_attr = product_class.findAttr("NAME"); POLAttr desp_attr = product_class.findAttr("DESCRIPTION"); // initialize all the attributes of the newly created object POLPersistentCapable new_obj = product_class.createNewObj(product_group); new_obj.getObjHdl().setIntVal(pid_attr, 1000); new_obj.getObjHdl().setCharArrayVal(name_attr, "Book".toCharArray()); new_obj.getObjHdl().setCharArrayVal(desp_attr, "DDJ".toCharArray()); ; // find all the product object POLIterator it = new POLIterator(product_group, product_class, true, ""); while (it.hasMoreElements()) { POLPersistentCapable obj = it.next(); System.out.println("PID = " + obj.getObjHdl().getIntVal(pid_attr)); System.out.println("NAME = " +new String(obj.getObjHdl().getCharArrayVal(name_attr))); System.out.println("DESP = " +new String(obj.getObjHdl().getCharArrayVal(desp_attr))+"\n"); } pcon.commit(); // disconnect from database pcon.disconnect(); } catch ( POLException e) { // catch error System.out.println("Errno = " + e.getErrNo()); } catch (Exception ee) { System.out.println("Message = " + ee.getMessage()); } } }