code: private ODatabaseDocument checkOpened(final ODatabaseDocument db) {
          Preconditions.checkState(orientDB.get().isOpen(), "Global OrientDB object is closed. "
                  + "This must be the result of manual object closing.");
          Preconditions.checkState(!db.isClosed(), String.format(
                  "Inconsistent %s pool state: thread-bound database closed! "
                          + "This may happen if close, commit or rollback was called directly on "
                          + "database connection object, which is not allowed (if you need full control "
                          + "on connection use manual setup and not pool managed connection)", getType()));
          return db;
      }
docs: To early catch inconsistency errors it's better to check here (should reduce scope to search for problem).
  It's so easy to call close directly on connection, but it shouldn't be done manually: either use unit of work
  or completely manage connection yourself.
  
  @param db database connection instance
  @return connection instance if its opened, otherwise error thrown