Home » Support » Forum » Open several objectdb databases the same time

Open several objectdb databases the same time

#1

We tried to open objectdb databases from application and got following error:

Attempt to open a database file 'D:\tmp\PAT-707\TC_9_2_3_1_8b@2015-09-17_12.08.15\TC_9_2_3_1_8b@2015-09-17_12.08.15.pa3' that is currently in use by another process (error 141)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:260)
at com.anritsu.pa3.application.pa3datastore.AppDataStoreManager.doOpenDataStore(AppDataStoreManager.java:252)
at com.anritsu.pa3.application.pa3datastore.AppDataStoreManager.openDataStore(AppDataStoreManager.java:63)
at com.anritsu.pa3.application.pa3guiapplication.managers.AppDataImportManager$4.run(AppDataImportManager.java:487)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.objectdb.o.UserException: Attempt to open a database file 'D:\tmp\PAT-707\TC_9_2_3_1_8b@2015-09-17_12.08.15\TC_9_2_3_1_8b@2015-09-17_12.08.15.pa3' that is currently in use by another process
at com.objectdb.o.MSG.d(MSG.java:62)
at com.objectdb.o.LFL.G(LFL.java:934)
at com.objectdb.o.LFL.B(LFL.java:880)
at com.objectdb.o.LFL.B(LFL.java:790)
at com.objectdb.o.SFL.<init>(SFL.java:235)
at com.objectdb.o.MST.<init>(MST.java:123)
at com.objectdb.o.MST.aM(MST.java:105)
at com.objectdb.o.MSF.U1(MSF.java:188)
at com.objectdb.o.OMF.ao(OMF.java:777)
at com.objectdb.jpa.EMF.ao(EMF.java:238)
at com.objectdb.o.OMF.an(OMF.java:690)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:257)
... 4 more

Is it possible to open object db files in read only mode from several application instances?

Symphony Teleca (Harman)
#2

In embedded mode a database can only be accessed by one process at a time.

The server mode is designed for accessing a database by several processes simultaneously.

You may also try the undocumented embedded-server mode, in which the first process opens the database in embedded mode but also starts an internal server, and additional processes can connect the that database using regular embedded mode API, but actually these additional database connections are implemented as client-server connections.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

What about database access performance (read/write speed) after re-configuring open a database with socket model? Do you have any metrics?

Symphony Teleca (Harman)
#4

The first process will have the performance of embedded mode and the others will have the performance of server mode, which is slower.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

Brilliant! I can confirm that using undocumented option in ObjectDb configuration file is allowing to open several databases on different application instances! Following steps are required:

1. Update in conf file following section

<server>
  <connection port="6136" max="100" />
  <data path="$objectdb/db" />
  <embedded-server enabled="true" />
  <!--
  <replication url="objectdb://localhost/test.odb;user=admin;password=admin" />
  -->
</server>

2. Use in source code following rules:

try
{
   // For first and other connections
   m_EntityMgrFactory = Persistence.createEntityManagerFactory( String.format( "objectdb:%s;port=3333", aFilename ) );
   m_EntityManager = m_EntityMgrFactory.createEntityManager();
}
catch ( Exception aException )
{
   // For second and other connections
   m_EntityMgrFactory = Persistence.createEntityManagerFactory( "objectdb://localhost:3333/;user=admin;password=admin" );
   m_EntityManager = m_EntityMgrFactory.createEntityManager();
}

Also, I didn't face any speed differences between EMBEDDED & SERVER modes, but both methods should be profiled for details, of course!

Symphony Teleca (Harman)
#6

hello i am making a desktop application that uses objectdb and my requirement is to share database so i create new config file and do whatever you show in page but its not working .....

[ObjectDB 2.7.4] javax.persistence.PersistenceException
Attempt to open a database file 'Z:\dist\gaapmrp1.odb' that is currently in use
by another process (error 141)

can u please help me to solve this problem

 

Prateek
#7

A possible cause is that the configuration file that you prepared with embedded-server enabled is not used by your application. Please check the log file to see the path of the configuration file that is actually being used by your application.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login