0

Trying to fetch records from orientdb. I am getting below error:

Exception in thread "main" com.orientechnologies.orient.core.exception.ODatabaseException: Database 'remote:localhost/testdb' is closed
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.checkOpenness(ODatabaseDocumentAbstract.java:2328)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentRemote.fetchNextPage(ODatabaseDocumentRemote.java:446)
at com.orientechnologies.orient.client.remote.message.ORemoteResultSet.fetchNextPage(ORemoteResultSet.java:52)
at com.orientechnologies.orient.client.remote.message.ORemoteResultSet.hasNext(ORemoteResultSet.java:47)
at com.orientechnologies.orient.core.sql.executor.OResultSet.tryAdvance(OResultSet.java:41)
at java.util.Spliterator.forEachRemaining(Spliterator.java:326)
at com.orientechnologies.orient.core.sql.executor.OResultSet.forEachRemaining(OResultSet.java:49)
at aoa.services.impl.OrientdConnectionHandler.getResultList(OrientdConnectionHandler.java:197)
at aoa.services.impl.OrientdConnectionHandler.main(OrientdConnectionHandler.java:209)

Querying data using below code :

   ...
    try(ODatabaseSession ses_orient = getConnPool(dbnae).acquire();){
      rs = ses_orient.query(query);  
    }


    public ODatabasePool getConnPool(String dbname){
      ODatabasePool pool = new 
       ODatabasePool(orientDB,dbname,OrientDbConFactory.USER,OrientDbConFactory.PASSWORD, 
       orientDBConfig);
       connPool.put(dbname,pool);
       return pool;
    }
   ...

The query works fine if I limit number of records to 1000 which is 'QUERY_REMOTE_RESULTSET_PAGE_SIZE'. If number of records is more than 1000, I am getting error : Database 'remote:localhost/testdb' is closed

2
  • can you change the title: you're not using the JDBC driver of Orientdb Apr 8, 2020 at 11:14
  • the ses_orient is closed by the try (with resource), so is the rs. YOu should consume the rs inside the try block. I guess Apr 8, 2020 at 13:22

1 Answer 1

1

I think you are consuming the OResultSet outside the Try block, this means that the session is closed and the rs can't fetch more data from the database anymore.

 try(ODatabaseSession ses_orient = getConnPool(dbnae).acquire();){
     OResultSet rs = ses_orient.query(query);
     rs.stream()
        .forEach(x -> System.out.println(x.getProperty("propertyName")));
     rs.close();

}

Reference documentation:

http://orientdb.com/docs/3.0.x/java/Java-Query-API.html

1
  • Yes, that was the thing. I was fetching data from OResultSet after session was closed.
    – Omi A
    Apr 9, 2020 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.