Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. PersistenceUnitMetaData pumd = new PersistenceUnitMetaData("dynamic-unit", "RESOURCE_LOCAL", null);
  2. pumd.addClassName("com.company.DataObject");
  3. pumd.setExcludeUnlistedClasses(true);
  4. pumd.addProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory"); //TODO
  5. pumd.addProperty("javax.jdo.option.ConnectionDriverName", "com.mysql.jdbc.Driver");
  6. pumd.addProperty("javax.jdo.option.ConnectionURL", "jdbc:mysql://127.0.0.1:3306/test?useSSL=false"); //"jdbc:h2:mem:mypersistence"
  7. pumd.addProperty("javax.jdo.option.ConnectionUserName", "user");
  8. pumd.addProperty("javax.jdo.option.ConnectionPassword", "123456");
  9. pumd.addProperty("datanucleus.autoCreateSchema", "true");
  10. pumd.addProperty("datanucleus.schema.autoCreateTables", "true");
  11.  
  12. PersistenceManager pm = new JDOPersistenceManagerFactory(pumd, null).getPersistenceManager();
  13. p(pm.getClass().getName());
  14. Transaction tr = pm.currentTransaction();
  15. tr.begin();
  16. DataObject t=new DataObject();
  17. t.sellData=Long.MAX_VALUE;
  18. t.state="true";
  19. t.teleportData="";
  20. pm.makePersistent(t);
  21. tr.commit();
  22. pm.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement