Database is closed Exception

32 views
Skip to first unread message

Academia Learning Centro de inglés y de formación

unread,
Nov 24, 2016, 5:04:08 AM11/24/16
to orient-...@googlegroups.com
Hello I wanted to ask if I am doing this correctly or am doing something wrong, I initialize it like this:
Class orientDBService
OrientGraphFactory oFactory = new OrientGraphFactory (this.databaseURI).setupPool(1,10);;
this.graph = oFactory.getTx();


Then I have two methods one to create a Vertex and another to recover it
public void insertComposition(EhrId ehrId, CompositionData compositionData) {    
    OrientGraph graph = orientDBService.getGraph();    
    try{    
    Vertex compositionVersion = (Vertex) graph.command( new OCommandSQL("insert into CompositionVersions set value = " + compositionData.asJSON()) ).execute();   
   
    }catch( Exception e ) {    
    graph.rollback();
    }finally {
    graph.shutdown();
    }
    }


recover function
public CompositionData getComposition(String compositionId) {
OrientGraph graph = orientDBService.getGraph();
Vertex composition = null;
    try{    
    Iterable<OrientVertex> resultComposition = graph
    .command( new OCommandSQL("SELECT expand (out('hasVersions')) as this FROM Composition WHERE idComposition = "5") ).execute();
    if (resultComposition.iterator().hasNext()){
    composition = (Vertex) resultComposition.iterator().next();
    }
   
    }catch( Exception e ) {    
    graph.rollback();
    }finally {
     graph.shutdown();
    }
   
    return CompositionData.fromJSON(composition.getProperty("this").toString());
    }


This gives me the exception: Database is closed, However if I do not use graph.shutdown the data is not yet persistent

Ivan Mainetti

unread,
Nov 24, 2016, 6:05:38 AM11/24/16
to OrientDB
could you post the exception?
which part of the code throws it?

Academia Learning Centro de inglés y de formación

unread,
Nov 24, 2016, 7:03:23 AM11/24/16
to orient-...@googlegroups.com
In the 2º function when tries to run the command sql, give exception: Database is closed (because in ther first function I have done graph.shutdown();)

Ivan Mainetti

unread,
Nov 24, 2016, 7:24:27 AM11/24/16
to OrientDB
please post at least the full stacktrace

Academia Learning Centro de inglés y de formación

unread,
Nov 24, 2016, 8:01:38 AM11/24/16
to OrientDB
yes,

[com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.makeActive(OrientBaseGraph.java:361), com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.command(OrientBaseGraph.java:1783), com.indra.mymed.drm.openehr.test.orientdb.OrientDBOperations.getComposition(OrientDBOperations.java:252), com.indra.mymed.drm.openehr.test.OpenEHRBaseTest.test4CompositionInsertAndRetrieve(OpenEHRBaseTest.java:137), com.indra.mymed.drm.openehr.test.orientdb.OrientDBTest.test4CompositionInsertAndRetrieve(OrientDBTest.java:42), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:606), org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50), org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12), org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47), org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17), org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75), org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86), org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84), org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325), org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252), org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94), org.junit.runners.ParentRunner$3.run(ParentRunner.java:290), org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71), org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288), org.junit.runners.ParentRunner.access$000(ParentRunner.java:58), org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268), org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26), org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61), org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27), org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70), org.junit.runners.ParentRunner.run(ParentRunner.java:363), org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191), org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86), org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)]

Oleksandr Gubchenko

unread,
Nov 24, 2016, 4:51:46 PM11/24/16
to OrientDB
Which version are you using?

Academia Learning Centro de inglés y de formación

unread,
Nov 25, 2016, 2:51:39 AM11/25/16
to OrientDB
The last version, I downloaded it recently
Reply all
Reply to author
Forward
0 new messages