Hi,
please check following codes and also Exception of full stack trace.
Using Embedded Mode
public class Clent {
public static void main(String[] args) {
try{
Getter gtr;
EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb:testmemory.mem");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
gtr = new Getter(1, "john");
em.persist(gtr);
em.getTransaction().commit();
System.out.println("Success....");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Exception:
run:
Exception in thread "main" java.lang.NullPointerException
at com.objectdb.o.RPM.f(RPM.java:152)
at com.objectdb.o.RPM.<init>(RPM.java:111)
at com.objectdb.o.RQC.<init>(RQC.java:68)
at com.objectdb.o.MSF.h(MSF.java:272)
at com.objectdb.o.MSF.YP(MSF.java:192)
at com.objectdb.o.OMF.r(OMF.java:783)
at com.objectdb.jpa.EMF.r(EMF.java:130)
at com.objectdb.o.OMF.w(OMF.java:694)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:149)
at test.Server.main(Server.java:25)
C:\Users\Admin\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
Using Server mode
public class MyClient {
public static void main(String[] args) {
try{
SetterClass strc;
EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb://localhost:6137/
myclienttest.mem;user=admin;password=admin");
EntityManager em = emf.createEntityManager(); em.getTransaction().begin();
strc = new SetterClass(1, "john");
em.persist(strc);
em.getTransaction().commit();
System.out.println("Success....");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Exception:
run:
java.lang.NullPointerException
at com.objectdb.o.RPM.f(RPM.java:152)
at com.objectdb.o.RPM.<init>(RPM.java:111)
at com.objectdb.o.RQC.<init>(RQC.java:68)
at com.objectdb.o.MSF.h(MSF.java:272)
at com.objectdb.o.MSF.YP(MSF.java:192)
at com.objectdb.o.SHN.X(SHN.java:305)
at com.objectdb.o.SHN.Q(SHN.java:259)
at com.objectdb.o.SHN.w(SHN.java:123)
at com.objectdb.o.HND.run(HND.java:134)
at java.lang.Thread.run(Thread.java:745)
BUILD SUCCESSFUL (total time: 0 seconds)
Both codes are not working,
I need this way,please help me. if it is not the genuine way, give me some suggestion. if any changes in objectdb.conf file give me the that codes also.
Thank you.