lg.lindstrom
lg.lindstrom

Reputation: 856

How to access a OrientDB emedded database from a remote client?

I have written a small application running OrientDB embedded. It works well. I can read and write to the database from the applicatiom using a plocal connection.

Now I am trying to access the same database from a remote OrientDB client (from a another PC).

I am getting a error message telling me that the database is locked and cant be accessed.

Is there a work around for this, or are I doing something wrong?

Using Java and OrienDB 2.2.12

Upvotes: 1

Views: 151

Answers (1)

Oleksandr Gubchenko
Oleksandr Gubchenko

Reputation: 1369

You can try this code for connection:

private static final String dbUrl = "remote:localhost/databaseName";
private static final String dbUser = "admin";
private static final String dbPassword = "admin";

public static void createDBIfDoesNotExist() throws IOException {

    OServerAdmin server = new OServerAdmin(dbUrl).connect(dbUser, dbPassword);
    if (!server.existsDatabase("plocal")) {
        server.createDatabase("graph", "plocal");
    }
    server.close();
}

public static void connectToDBIfExists() throws IOException {

    OServerAdmin server = new OServerAdmin(dbUrl).connect(dbUser, dbPassword);

    // some code

    server.close();
}

Upvotes: 0

Related Questions