Java Reference
In-Depth Information
/** constructor */
public TestClient() {
System.out.println("First initializing JDO PersistenceManagerFactory");
try {
Properties props = new Properties();
props.setProperty("javax.jdo.PersistenceManagerFactoryClass",
"com.prismt.j2ee.jdo.PersistenceManagerFactoryImpl");
// Following part uses vendor specif APIs. Modify it as needed!
pmf = JDOHelper.getPersistenceManagerFactory(props);
pmf.setConnectionFactory( createConnectionFactory() );
} catch(Exception ex) {
ex.printStackTrace();
System.exit(1);
}
}
public static Object createConnectionFactory() {
ManagedConnectionFactoryImpl mcfi = new ManagedConnectionFactoryImpl();
Object connectionFactory = null;
try {
mcfi.setUserName("system");
mcfi.setPassword("manager");
mcfi.setConnectionURL("jdbc:oracle:thin:@localhost:1521:thedb");
mcfi.setDBDriver("oracle.jdbc.driver.OracleDriver");
connectionFactory = mcfi.createConnectionFactory();
} catch(Exception e) {
e.printStackTrace();
System.exit(1);
}
return connectionFactory;
}
/** Create a group of Yacht objects for persistence test */
public void yachtPersistor() {
// Create an array of three yachts to persist
yachts = new Yacht[SIZE];
yachts[0] = new Yacht("Whaler", "Grand Banks", "Twin Diesel", 12, 35);
yachts[1] = new Yacht("Liberty", "Bristol", "Single Diesel", 10, 25);
yachts[2] = new Yacht("Yifei", "Eastbay", "Twin Diesel", 8, 27 );
yachts[3] = new Yacht("Lightning", "Eastbay", "Twin Diesel", 8, 30 );
// get a PM and set transaction
pm = pmf.getPersistenceManager();
Search WWH ::




Custom Search