Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PersistenceUnitMetaData pumd = new PersistenceUnitMetaData("dynamic-unit", "RESOURCE_LOCAL", null);
- pumd.addClassName("com.company.DataObject");
- pumd.setExcludeUnlistedClasses(true);
- pumd.addProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory"); //TODO
- pumd.addProperty("javax.jdo.option.ConnectionDriverName", "com.mysql.jdbc.Driver");
- pumd.addProperty("javax.jdo.option.ConnectionURL", "jdbc:mysql://127.0.0.1:3306/test?useSSL=false"); //"jdbc:h2:mem:mypersistence"
- pumd.addProperty("javax.jdo.option.ConnectionUserName", "user");
- pumd.addProperty("javax.jdo.option.ConnectionPassword", "123456");
- pumd.addProperty("datanucleus.autoCreateSchema", "true");
- pumd.addProperty("datanucleus.schema.autoCreateTables", "true");
- PersistenceManager pm = new JDOPersistenceManagerFactory(pumd, null).getPersistenceManager();
- p(pm.getClass().getName());
- Transaction tr = pm.currentTransaction();
- tr.begin();
- DataObject t=new DataObject();
- t.sellData=Long.MAX_VALUE;
- t.state="true";
- t.teleportData="";
- pm.makePersistent(t);
- tr.commit();
- pm.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement