Database absolute filepath

#1

Is there a line of code that can be used to print out my databases absolute path?

I have set it as follows:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("$objectdb/database/people.odb");

However, the data being shown in \lib\objectdb\database\people.odb is different than what is being used in the rest of the application so I think there might be more than one database somehow.

#2

ObjectDB 2.5.7 adds the ability to retrieve connection details.

Please try the following test program (with version 2.5.7):

import javax.persistence.*;

public final class T1523
{
    public static void main(String[] args) {

        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory(
                "objectdb:$objectdb/db/test.tmp;drop");
        System.out.println(emf.getProperties());
        System.out.println(emf.getProperties().get("objectdb.connection.path"));

        EntityManager em = emf.createEntityManager();
        System.out.println(em.getProperties());
        System.out.println(em.getProperties().get("objectdb.connection.path"));

        em.close();
        emf.close();
    }
}
ObjectDB Support
#3

Why did you call it test.tmp instead of test.odb?

What does the keyword drop at the end of the line do?

#4

The drop parameter indicates a request to discard an old database (if exists) and create a new empty database. By default it works only for database files with the temp / tmp file name extensions.

ObjectDB Support

Reply