Exemplo n.º 1
0
 /** Invalidate the handle, called by txn.abort by way of DbInternal. */
 synchronized void invalidate() {
   state = INVALID;
   envHandle.removeReferringHandle(this);
   if (databaseImpl != null) {
     databaseImpl.removeReferringHandle(this);
   }
 }
Exemplo n.º 2
0
 public synchronized void close__wrappee__base() throws DatabaseException {
   StringBuffer errors = null;
   checkEnv();
   checkProhibitedDbState(CLOSED, "Can't close Database:");
   this.hook44();
   removeAllTriggers();
   envHandle.removeReferringHandle(this);
   if (cursors.size() > 0) {
     errors = new StringBuffer("There are open cursors against the database.\n");
     errors.append("They will be closed.\n");
     Iterator iter = cursors.copy().iterator();
     while (iter.hasNext()) {
       Cursor dbc = (Cursor) iter.next();
       try {
         dbc.close();
       } catch (DatabaseException DBE) {
         errors.append("Exception while closing cursors:\n");
         errors.append(DBE.toString());
       }
     }
   }
   if (databaseImpl != null) {
     databaseImpl.removeReferringHandle(this);
     databaseImpl = null;
     handleLocker.setHandleLockOwner(true, this, true);
     handleLocker.operationEnd(true);
     state = CLOSED;
   }
   if (errors != null) {
     throw new DatabaseException(errors.toString());
   }
 }
Exemplo n.º 3
0
  public synchronized void close() throws DatabaseException {

    StringBuffer errors = null;

    checkEnv();
    checkProhibitedDbState(CLOSED, "Can't close Database:");

    trace(Level.FINEST, "Database.close: ", null, null);

    /* Disassociate triggers before closing. */
    removeAllTriggers();

    envHandle.removeReferringHandle(this);
    if (cursors.size() > 0) {
      errors = new StringBuffer("There are open cursors against the database.\n");
      errors.append("They will be closed.\n");

      /*
       * Copy the cursors set before iterating since the dbc.close()
       * mutates the set.
       */
      Iterator iter = cursors.copy().iterator();
      while (iter.hasNext()) {
        Cursor dbc = (Cursor) iter.next();

        try {
          dbc.close();
        } catch (DatabaseException DBE) {
          errors.append("Exception while closing cursors:\n");
          errors.append(DBE.toString());
        }
      }
    }

    if (databaseImpl != null) {
      databaseImpl.removeReferringHandle(this);
      databaseImpl = null;

      /*
       * Tell our protecting txn that we're closing. If this type
       * of transaction doesn't live beyond the life of the handle,
       * it will release the db handle lock.
       */
      handleLocker.setHandleLockOwner(true, this, true);
      handleLocker.operationEnd(true);
      state = CLOSED;
    }

    if (errors != null) {
      throw new DatabaseException(errors.toString());
    }
  }