client server mod of communication

#1

Hi,
   I want to use in client Server mode one is client and another in server mode. Assume that one server is there and 'n' number of clients are there each client wants to communicate with server, in client server mode.
   1)EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb://localhost:6137/settercode.odb;user=admin;password=admin");
   2)EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb://localhost:6137/settercode.mem;user=admin;password=admin");

    i do not want to first one, i want second one only and please tell me is it possible or not if possible what is the way to do that, if it is not possible why, i am trying this one but i finding Exception:NullpointerException.

Thank you

#2

Please explain your question. It is unclear what you are trying to do.

ObjectDB Support
#3

Hi,

Simply, my question is i want to store my object in server mode and also to check my database using server mode, and its extension must be (.mem) like  test.mem not in test.odb.

Assume that there are two project one is for client and another is for server they want to access same database, one is use for write(store) data and another one is use to read the data at the same time. When server is stop then the database automatically destroy.  

Persistence.createEntityManagerFactory("objectdb://localhost:6137/settercode.mem;user=admin;pass=admin;); in this way.

Thank you.

#4

Are you asking if a database file could have a suffix ".mem"? The answer is yes.

If a NullPointerException is thrown then please post the full stack trace.

ObjectDB Support
#5

On a second thought, your question is probably:

    Can I use in-memory mode with client-server mode?

Please confirm that this is the question as it is quite far from the title of this thread and the original post.

The answer to this question is:

    Currently you cannot. In-memory mode is only supported in embedded mode.

But we will check if support could be added.

ObjectDB Support
#6

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.

#7

The stack trace indicates using recording, which may not be supported with memory databases.

Please try to disable recording.

ObjectDB Support

Reply