package examples.dbo; import java.sql.*; import java.util.*; import fc.io.*; import fc.util.*; public class Save extends Test { public void test(Args myargs, Connection con) throws Exception { System.out.println("Creates a new bean representing a row in table mollytest and saves it."); mollytest bean = null; System.out.println(">>> Created a new bean"); bean = new mollytest(); System.out.println(bean); System.out.println(">>> Setting various values in the new bean"); bean.set_name("Molly Kolodny"); bean.set_email("mol@holografix.net"); bean.set_password("blue9"); bean.set_is_active(true); bean.set_created_on(new java.sql.Date(System.currentTimeMillis())); System.out.println(">>> After setting values in the new bean"); System.out.println(bean); con.setAutoCommit(false); System.out.println("Now SAVING....(this should work)..."); try { start(); mollytestMgr.save(con, bean); con.commit(); System.out.println(">>> Save successful"); } catch (Exception e) { System.out.println("ERROR COULD NOT SAVE....."); e.printStackTrace(); System.out.println("Rolling back..."); con.rollback(); System.exit(1); } System.out.println(">>> After saving the bean [Note: the serial/auto-increment uid is now available !]"); System.out.println(bean); } }