Orientdb Cant open Database from Java

天涯浪子 提交于 2019-12-12 09:44:15

问题


I created a database out of the orientdb console:

create database plocal:/C:/Development/orientdb/databases/testdb root root plocal graph

I started the server to make sure my database was created successfully. I opened the webinterface:

localhost:2480

And i logged in into testdb using root as user and root as password. Everything worked fine. But when i now want to connect to my database from Java-Code:

    OrientGraph graph = null;

    try {
        graph = new OrientGraph("plocal:C:/Development/orientdb/databases/testdb", "root", "root");

        System.out.println("success");
    } catch(OException e) {
        System.out.println("no success - " + e.getMessage());

        e.printStackTrace();
    } finally {
        if(graph != null) {
            graph.shutdown();
        }
    }

I get the following exception:

Exception in thread "main" com.orientechnologies.orient.core.exception.OSecurityAccessException: User or password not  valid for database: 'testdb'
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.authenticate(OSecurityShared.java:150)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.authenticate(OSecurityProxy.java:83)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:128)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.orientechnologies.orient.core.db.graph.OGraphDatabase.open(OGraphDatabase.java:92)
at de.hof.iisys.relationExtraction.freebase.tinkerpop.DAO.openGraph(DAO.java:30)
at de.hof.iisys.relationExtraction.freebase.main.Main.main(Main.java:44)

Why he is telling me that username or password is wrong when its not?


回答1:


In "create database" command from the console, user and password are used only to authenticate against a remote database. With "plocal", "local" and "memory" URL the admin user is always "admin" with password "admin".

So use:

graph = new OrientGraph("plocal:C:/Development/orientdb/databases/testdb", "admin", "admin");

Starting from OrientDB 1.7-SNAPSHOT the console accepts only the URL for such cases:

create database plocal:/C:/Development/orientdb/databases/testdb


来源:https://stackoverflow.com/questions/22890957/orientdb-cant-open-database-from-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!