Use tinkerpop/gremlin with embedded database

Hi,
I am looking for a way to use the tinkerpop/gremlin driver with an embedded orientdb.

I first start the server with OServerMain.create() and then open the DB using server.openDatabase(), which returns an instance of ODatabaseDocumentInternal. How can I (re-)use this instance to open a new OrientGraph instance? Or is there another way to connect to the embedded db?

I am using 3.0.18

Thanks
Jon

Ok after 1 day of searching through the whole web and putting all puzzle pieces together I finally found a solution:

OServer server = OServerMain.create();
server.startup(getOrientServerConfig());
server.activate();
        
OrientDB db = server.getContext(); // re-use the existing db context 
factory = new OrientGraphFactory(db, dbName, ODatabaseType.PLOCAL, "admin", "admin").setupPool(1,10); // important user/pw MUST be admin/admin with plocal, even though your created db has other credentials

Sources


The only problem is now that when I create a schema of my database like this:

ODatabaseDocumentInternal database = server.openDatabase(dbName, "admin", "admin");
                // import schema
                ODatabaseImport dbImport = new ODatabaseImport(database, "config/schema.gz", listener);
                dbImport.importDatabase();
                dbImport.close();
                database.close();

and restart the app/db, the new OrientGraphFactory(..) fails with:

com.orientechnologies.orient.core.exception.OSecurityAccessException: User or password not valid for database: 'XX'
	DB name="XX"

It seems that the import bricks the db somehow. Any ideas?