我正在为我的应用程序使用Orient图数据库。我正在使用Java api,如下所示。
package Sample.Sample;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
OrientGraph graph = new OrientGraph("plocal:C://orientdb-3.0.11//databases//Example1","admin", "admin");
try {
Vertex vPerson = graph.addVertex("class:Persona");
vPerson.setProperty("firstName", "John");
vPerson.setProperty("lastName", "Smith");
Vertex vAddress = graph.addVertex("class:Addressa");
vAddress.setProperty("street", "Van Ness Ave.");
vAddress.setProperty("city", "San Francisco");
vAddress.setProperty("state", "California");
} finally {
graph.shutdown();
}
}
}
我正在使用OrientGraph对象连接到数据库,但是连接到数据库时却出现了空指针异常(如下所示的异常)。
OrientGraph图=新的OrientGraph(“ plocal:C://orientdb-3.0.11//databases//Example1”,“ admin”,“ admin”);
错误是因为上面的行,即使我用单斜杠替换了双正斜杠,但仍然存在错误
java.lang.NullPointerException
at com.orientechnologies.orient.core.storage.index.sbtree.local.OSBTree.iterateEntriesBetweenAscOrder(OSBTree.java:1438)
at com.orientechnologies.orient.core.storage.index.sbtree.local.OSBTree.iterateEntriesBetween(OSBTree.java:955)
at com.orientechnologies.orient.core.storage.index.engine.OSBTreeIndexEngine.iterateEntriesBetween(OSBTreeIndexEngine.java:188)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doIterateIndexEntriesBetween(OAbstractPaginatedStorage.java:2912)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.iterateIndexEntriesBetween(OAbstractPaginatedStorage.java:2891)
at com.orientechnologies.orient.core.index.OIndexOneValue.iterateEntriesBetween(OIndexOneValue.java:156)
at com.orientechnologies.orient.core.index.OIndexAbstractDelegate.iterateEntriesBetween(OIndexAbstractDelegate.java:110)
at com.orientechnologies.orient.core.index.OIndexTxAwareOneValue.iterateEntriesBetween(OIndexTxAwareOneValue.java:262)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:371)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.processAndBlock(FetchFromIndexStep.java:312)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:235)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:216)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.syncPull(FetchFromIndexStep.java:81)
at com.orientechnologies.orient.core.sql.executor.GetValueFromIndexEntryStep$1.fetchNextItem(GetValueFromIndexEntryStep.java:92)
at com.orientechnologies.orient.core.sql.executor.GetValueFromIndexEntryStep$1.hasNext(GetValueFromIndexEntryStep.java:58)
at com.orientechnologies.orient.core.sql.executor.FilterByClassStep$1.fetchNextItem(FilterByClassStep.java:50)
at com.orientechnologies.orient.core.sql.executor.FilterByClassStep$1.hasNext(FilterByClassStep.java:88)
at com.orientechnologies.orient.core.sql.parser.OLocalResultSet.fetchNext(OLocalResultSet.java:42)
at com.orientechnologies.orient.core.sql.parser.OLocalResultSet.<init>(OLocalResultSet.java:32)
at com.orientechnologies.orient.core.sql.parser.OSelectStatement.execute(OSelectStatement.java:267)
at com.orientechnologies.orient.core.sql.parser.OStatement.execute(OStatement.java:62)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.query(ODatabaseDocumentEmbedded.java:518)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.lambda$getUser$0(OSecurityShared.java:616)
at com.orientechnologies.orient.core.db.OScenarioThreadLocal.executeAsDistributed(OScenarioThreadLocal.java:88)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.getUser(OSecurityShared.java:615)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.authenticate(OSecurityShared.java:233)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.authenticate(OSecurityProxy.java:107)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.internalOpen(ODatabaseDocumentEmbedded.java:178)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.internalOpen(ODatabaseDocumentEmbedded.java:167)
at com.orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:149)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:870)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.openOrCreate(OrientBaseGraph.java:1992)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:166)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:103)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:99)
at com.tinkerpop.blueprints.impls.orient.OrientGraph.<init>(OrientGraph.java:105)
at Sample.Sample.App.main(App.java:21)
Exception in thread "main" com.orientechnologies.orient.core.exception.ODatabaseException: Cannot open database 'Example1'
at com.orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:153)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:870)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.openOrCreate(OrientBaseGraph.java:1992)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.<init>(OrientBaseGraph.java:166)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:103)
at com.tinkerpop.blueprints.impls.orient.OrientTransactionalGraph.<init>(OrientTransactionalGraph.java:99)
at com.tinkerpop.blueprints.impls.orient.OrientGraph.<init>(OrientGraph.java:105)
at Sample.Sample.App.main(App.java:21)
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: Cannot open database url=plocal:C:\orientdb-3.0.11\databases/Example1
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.internalOpen(ODatabaseDocumentEmbedded.java:195)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.internalOpen(ODatabaseDocumentEmbedded.java:167)
at com.orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:149)
... 7 more
Caused by: java.lang.NullPointerException
at com.orientechnologies.orient.core.storage.index.sbtree.local.OSBTree.iterateEntriesBetweenAscOrder(OSBTree.java:1438)
at com.orientechnologies.orient.core.storage.index.sbtree.local.OSBTree.iterateEntriesBetween(OSBTree.java:955)
at com.orientechnologies.orient.core.storage.index.engine.OSBTreeIndexEngine.iterateEntriesBetween(OSBTreeIndexEngine.java:188)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doIterateIndexEntriesBetween(OAbstractPaginatedStorage.java:2912)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.iterateIndexEntriesBetween(OAbstractPaginatedStorage.java:2891)
at com.orientechnologies.orient.core.index.OIndexOneValue.iterateEntriesBetween(OIndexOneValue.java:156)
at com.orientechnologies.orient.core.index.OIndexAbstractDelegate.iterateEntriesBetween(OIndexAbstractDelegate.java:110)
at com.orientechnologies.orient.core.index.OIndexTxAwareOneValue.iterateEntriesBetween(OIndexTxAwareOneValue.java:262)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:371)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.processAndBlock(FetchFromIndexStep.java:312)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:235)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:216)
at com.orientechnologies.orient.core.sql.executor.FetchFromIndexStep.syncPull(FetchFromIndexStep.java:81)
at com.orientechnologies.orient.core.sql.executor.GetValueFromIndexEntryStep$1.fetchNextItem(GetValueFromIndexEntryStep.java:92)
at com.orientechnologies.orient.core.sql.executor.GetValueFromIndexEntryStep$1.hasNext(GetValueFromIndexEntryStep.java:58)
at com.orientechnologies.orient.core.sql.executor.FilterByClassStep$1.fetchNextItem(FilterByClassStep.java:50)
at com.orientechnologies.orient.core.sql.executor.FilterByClassStep$1.hasNext(FilterByClassStep.java:88)
at com.orientechnologies.orient.core.sql.parser.OLocalResultSet.fetchNext(OLocalResultSet.java:42)
at com.orientechnologies.orient.core.sql.parser.OLocalResultSet.<init>(OLocalResultSet.java:32)
at com.orientechnologies.orient.core.sql.parser.OSelectStatement.execute(OSelectStatement.java:267)
at com.orientechnologies.orient.core.sql.parser.OStatement.execute(OStatement.java:62)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.query(ODatabaseDocumentEmbedded.java:518)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.lambda$getUser$0(OSecurityShared.java:616)
at com.orientechnologies.orient.core.db.OScenarioThreadLocal.executeAsDistributed(OScenarioThreadLocal.java:88)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.getUser(OSecurityShared.java:615)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.authenticate(OSecurityShared.java:233)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.authenticate(OSecurityProxy.java:107)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.internalOpen(ODatabaseDocumentEmbedded.java:178)
... 9 more
我在哪里出错了?