Beispiel #1
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());
   }
 }
  /** static method testing jdbc framework with a simple select statement using parameters */
  public static void testSimpleSelectWithParams() {
    try {
      SQLExecutor sqlExec = new SQLExecutor(getConnectionPool());
      //            sqlExec.addParam(new Integer(8));
      sqlExec.addParam(8);
      sqlExec.addParam(Date.valueOf("2003-05-10"));
      SQLResults res = sqlExec.runQueryCloseCon(sqlSelect);

      String out = "SQL Results:\n";
      for (int row = 0; row < res.getRowCount(); row++)
        out +=
            res.getLong(row, "TEST_ID")
                + " "
                + res.getString(row, "NOTES")
                + " "
                + res.getDate(row, "TEST_DT")
                + " "
                + res.getDouble(row, "AMOUNT")
                + " "
                + res.getString(row, "CODE")
                + "\n";
      System.out.println(out);
    } catch (DatabaseException e) {
      if (e.isDataIntegrityViolation()) applyDataIntegrityViolationRecovery();
    }
  }
Beispiel #3
0
  public synchronized BookPrx[] findByAuthors(String authors, Ice.Current current)
      throws DatabaseException {
    try {
      //
      // Lookup all books that match the given authors, and
      // return them to the caller.
      //
      String[] isbnSeq = _authors.get(authors);

      int length = (isbnSeq == null) ? 0 : isbnSeq.length;
      BookPrx[] books = new BookPrx[length];

      if (isbnSeq != null) {
        for (int i = 0; i < length; ++i) {
          books[i] = isbnToBook(isbnSeq[i], current.adapter);
        }
      }

      return books;
    } catch (Freeze.DatabaseException ex) {
      DatabaseException e = new DatabaseException();
      e.message = ex.message;
      throw e;
    }
  }
    public void putWithTry(int numOps) {
      try {
        setup(true);
        for (int i = 0; i < numOps; i++) {
          TestObject object = new TestObject();
          String s = new Integer(i).toString();
          object.setSid(s);
          object.setName("hero" + s);
          object.setCountry("China");

          objectList.add(object);

          if (objectList.size() >= CACHE_LIMIT) {
            close();

            boolean success = false;
            while (!success) {
              success = setup(false);
            }

            for (int j = 0; j < objectList.size(); j++) {
              objectBySid.putNoReturn(objectList.get(j));
            }

            close();
            setup(true);
            objectList = new ArrayList<TestObject>();
          }
        }
      } catch (DatabaseException e) {
        e.printStackTrace();
      }
    }
Beispiel #5
0
 public void close() {
   try {
     urlsDB.close();
   } catch (DatabaseException e) {
     e.printStackTrace();
   }
 }
 /**
  * INTERNAL: Execute the query building the objects directly from the database result-set.
  *
  * @exception DatabaseException - an error has occurred on the database
  * @return object - the first object found or null if none.
  */
 protected Object executeObjectLevelReadQueryFromResultSet() throws DatabaseException {
   UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl) getSession();
   DatabaseAccessor accessor = (DatabaseAccessor) unitOfWork.getAccessor();
   DatabasePlatform platform = accessor.getPlatform();
   DatabaseCall call = (DatabaseCall) getCall().clone();
   call.setQuery(this);
   call.translate(this.translationRow, null, unitOfWork);
   Statement statement = null;
   ResultSet resultSet = null;
   boolean exceptionOccured = false;
   try {
     accessor.incrementCallCount(unitOfWork);
     statement = call.prepareStatement(accessor, this.translationRow, unitOfWork);
     resultSet = accessor.executeSelect(call, statement, unitOfWork);
     ResultSetMetaData metaData = resultSet.getMetaData();
     Vector results = new Vector();
     ObjectBuilder builder = this.descriptor.getObjectBuilder();
     while (resultSet.next()) {
       results.add(
           builder.buildWorkingCopyCloneFromResultSet(
               this,
               this.joinedAttributeManager,
               resultSet,
               unitOfWork,
               accessor,
               metaData,
               platform));
     }
     return results;
   } catch (SQLException exception) {
     exceptionOccured = true;
     DatabaseException commException =
         accessor.processExceptionForCommError(session, exception, call);
     if (commException != null) throw commException;
     throw DatabaseException.sqlException(exception, call, accessor, unitOfWork, false);
   } finally {
     try {
       if (resultSet != null) {
         resultSet.close();
       }
       if (statement != null) {
         accessor.releaseStatement(statement, call.getSQLString(), call, unitOfWork);
       }
     } catch (SQLException exception) {
       if (!exceptionOccured) {
         // in the case of an external connection pool the connection may be null after the
         // statement release
         // if it is null we will be unable to check the connection for a comm error and
         // therefore must return as if it was not a comm error.
         DatabaseException commException =
             accessor.processExceptionForCommError(session, exception, call);
         if (commException != null) throw commException;
         throw DatabaseException.sqlException(exception, call, accessor, session, false);
       }
     }
   }
 }
Beispiel #7
0
  public synchronized BookPrx createBook(BookDescription description, Ice.Current current)
      throws DatabaseException, BookExistsException {
    BookPrx book = isbnToBook(description.isbn, current.adapter);

    try {
      book.ice_ping();

      //
      // The book already exists.
      //
      throw new BookExistsException();
    } catch (Ice.ObjectNotExistException e) {
      //
      // Book doesn't exist, ignore the exception.
      //
    }

    //
    // Create a new book Servant.
    //
    BookI bookI = new BookI(this);
    bookI.description = description;

    Ice.Identity ident = createBookIdentity(description.isbn);

    //
    // Create a new Ice Object in the evictor, using the new
    // identity and the new Servant.
    //
    // This can throw EvictorDeactivatedException (which indicates
    // an internal error). The exception is currently ignored.
    //
    _evictor.add(bookI, ident);

    try {
      //
      // Add the isbn number to the authors map.
      //
      String[] isbnSeq = _authors.get(description.authors);
      int length = (isbnSeq == null) ? 0 : isbnSeq.length;
      String[] newIsbnSeq = new String[length + 1];

      if (isbnSeq != null) {
        System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, length);
      }
      newIsbnSeq[length] = description.isbn;

      _authors.fastPut(description.authors, newIsbnSeq);

      return book;
    } catch (Freeze.DatabaseException ex) {
      DatabaseException e = new DatabaseException();
      e.message = ex.message;
      throw e;
    }
  }
  /**
   * @param i
   * @param name
   * @throws DatabaseException
   * @throws SQLException
   */
  public Object getConfig(int i, String name) {
    String str = "";
    int in = 0;
    long lng = 0;
    double dbl = 0;
    boolean bln = false;
    try {
      Transaction trans = new JDBCTransaction(createConnection());
      Connection connection = ((JDBCTransaction) trans).getConnection();
      Statement stmt = connection.createStatement();

      String query = SQL_CONFIG_GET + "'" + name + "')";

      ResultSet result = stmt.executeQuery(query);
      if (result.next()) {
        switch (i) {
          case (SQL_BLN):
            {
              bln = result.getBoolean("value");
              return bln;
            }
          case (SQL_INT):
            {
              in = result.getInt("value");
              return in;
            }
          case (SQL_DBL):
            {
              dbl = result.getDouble("value");
              return dbl;
            }
          case (SQL_LNG):
            {
              lng = result.getLong("value");
              return lng;
            }
          case (SQL_STR):
            {
              str = result.getString("value");
              return str;
            }
        }
      } else {
        eng.LOG.printError("MySQL Error loading config: name = " + name + " type = " + i, null);
        return null;
      }
    } catch (DatabaseException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return null;
  }
  public void createAccount(String username, String password, String email, String bday)
      throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    Connection con = null;
    java.sql.Date bd = null;
    java.util.Date d = new java.util.Date();
    long t = d.getTime();
    java.sql.Timestamp date = new java.sql.Timestamp(t);
    date.setNanos(0);
    bd = bd.valueOf(bday);
    String ip = getIP();

    String query = "";
    // 66.172.33.253
    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      con =
          DriverManager.getConnection(
              "jdbc:mysql://localhost:3306/" + MYSQL_DB, MYSQL_USER, MYSQL_PW);
      if (!con.isClosed()) System.out.println("Successfully connected");
      Statement stmt = con.createStatement();
      Transaction trans = new JDBCTransaction(createConnection());

      if (userExists(trans, "login", username)) {
        System.out.println("error");
      } else {
        query =
            SQL_TBL_LOGIN_INS
                + "'"
                + username
                + "','"
                + password
                + "','"
                + email
                + "','"
                + ip
                + "','"
                + bday
                + "','"
                + date
                + "')";

        stmt.execute(query);
        loggedIn = true;
      }

      if (con != null) con.close();

    } catch (SQLException e) {
      e.printStackTrace();
    } catch (DatabaseException e) {
      e.printStackTrace();
    }
  }
Beispiel #10
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());
    }
  }
Beispiel #11
0
 public void sync() {
   if (resumable) {
     return;
   }
   if (urlsDB == null) {
     return;
   }
   try {
     urlsDB.sync();
   } catch (DatabaseException e) {
     e.printStackTrace();
   }
 }
 public void putNoTry(int numOps) {
   setup(false);
   try {
     for (int i = 0; i < numOps; i++) {
       TestObject object = new TestObject();
       String sId = new Integer(i).toString();
       object.setSid(sId);
       object.setName("hero" + sId);
       object.setCountry("China");
       objectBySid.putNoReturn(object);
     }
   } catch (DatabaseException e) {
     e.printStackTrace();
   }
 }
  /**
   * INTERNAL: Return the value of the field from the row or a value holder on the query to obtain
   * the object. Check for batch + aggregation reading.
   */
  public Object valueFromRow(
      AbstractRecord row,
      JoinedAttributeManager joinManager,
      ObjectBuildingQuery query,
      AbstractSession executionSession)
      throws DatabaseException {
    Ref ref = (Ref) row.get(getField());

    if (ref == null) {
      return null;
    }

    Struct struct;
    try {
      ((DatabaseAccessor) executionSession.getAccessor()).incrementCallCount(executionSession);
      java.sql.Connection connection =
          ((DatabaseAccessor) executionSession.getAccessor()).getConnection();
      struct =
          (Struct) executionSession.getPlatform().getRefValue(ref, executionSession, connection);
    } catch (java.sql.SQLException exception) {
      throw DatabaseException.sqlException(exception, executionSession, false);
    }
    AbstractRecord targetRow =
        ((ObjectRelationalDataTypeDescriptor) getReferenceDescriptor())
            .buildRowFromStructure(struct);
    ((DatabaseAccessor) executionSession.getAccessor()).decrementCallCount();

    return getReferenceDescriptor().getObjectBuilder().buildObject(query, targetRow, joinManager);
  }
  /** INTERNAL: Build a ADT structure from the row data. */
  public Struct buildStructureFromRow(
      AbstractRecord row, AbstractSession session, java.sql.Connection connection)
      throws DatabaseException {
    Struct structure;
    boolean reconnected = false;

    try {
      if (connection == null) {
        ((DatabaseAccessor) session.getAccessor()).incrementCallCount(session);
        reconnected = true;
        connection = ((DatabaseAccessor) session.getAccessor()).getConnection();
      }

      Object[] fields = new Object[getOrderedFields().size()];
      for (int index = 0; index < getOrderedFields().size(); index++) {
        DatabaseField field = (DatabaseField) getOrderedFields().elementAt(index);
        fields[index] = row.get(field);
      }

      structure =
          session.getPlatform().createStruct(getStructureName(), fields, session, connection);
    } catch (java.sql.SQLException exception) {
      throw DatabaseException.sqlException(exception, session, false);
    } finally {
      if (reconnected) {
        ((DatabaseAccessor) session.getAccessor()).decrementCallCount();
      }
    }

    return structure;
  }
  /**
   * INTERNAL: Build and return the appropriate field value for the specified set of nested rows.
   * The database better be expecting an ARRAY. It looks like we can ignore inheritance here....
   */
  public Object buildFieldValueFromNestedRows(
      Vector nestedRows, String structureName, AbstractSession session) throws DatabaseException {
    Object[] fields = new Object[nestedRows.size()];
    java.sql.Connection connection = ((DatabaseAccessor) session.getAccessor()).getConnection();
    boolean reconnected = false;

    try {
      if (connection == null) {
        ((DatabaseAccessor) session.getAccessor()).incrementCallCount(session);
        reconnected = true;
        connection = ((DatabaseAccessor) session.getAccessor()).getConnection();
      }

      int i = 0;
      for (Enumeration stream = nestedRows.elements(); stream.hasMoreElements(); ) {
        AbstractRecord nestedRow = (AbstractRecord) stream.nextElement();
        fields[i++] = this.buildStructureFromRow(nestedRow, session, connection);
      }

      return session.getPlatform().createArray(structureName, fields, session, connection);
    } catch (java.sql.SQLException exception) {
      throw DatabaseException.sqlException(exception, session, false);
    } finally {
      if (reconnected) {
        ((DatabaseAccessor) session.getAccessor()).decrementCallCount();
      }
    }
  }
Beispiel #16
0
 @Override
 public long allocPage() throws IOException {
   CommitLock.Shared shared = mCommitLock.acquireShared();
   try {
     return mPageManager.allocPage();
   } catch (DatabaseException e) {
     if (e.isRecoverable()) {
       throw e;
     }
     throw closeOnFailure(e);
   } catch (Throwable e) {
     throw closeOnFailure(e);
   } finally {
     shared.release();
   }
 }
Beispiel #17
0
  protected synchronized void remove(BookDescription description) throws DatabaseException {
    try {
      String[] isbnSeq = _authors.get(description.authors);

      assert isbnSeq != null;

      int i;
      for (i = 0; i < isbnSeq.length; ++i) {
        if (isbnSeq[i].equals(description.isbn)) {
          break;
        }
      }

      assert i < isbnSeq.length;

      if (isbnSeq.length == 1) {
        //
        // If there are no further associated isbn numbers then remove
        // the record.
        //
        _authors.fastRemove(description.authors);
      } else {
        //
        // Remove the isbn number from the sequence and write
        // back the new record.
        //
        String[] newIsbnSeq = new String[isbnSeq.length - 1];
        System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, i);
        if (i < isbnSeq.length - 1) {
          System.arraycopy(isbnSeq, i + 1, newIsbnSeq, i, isbnSeq.length - i - 1);
        }

        _authors.fastPut(description.authors, newIsbnSeq);
      }

      //
      // This can throw EvictorDeactivatedException (which
      // indicates an internal error). The exception is
      // currently ignored.
      //
      _evictor.remove(createBookIdentity(description.isbn));
    } catch (Freeze.DatabaseException ex) {
      DatabaseException e = new DatabaseException();
      e.message = ex.message;
      throw e;
    }
  }
Beispiel #18
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof DatabaseException)) return false;
   DatabaseException other = (DatabaseException) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && ((this.message1 == null && other.getMessage1() == null)
               || (this.message1 != null && this.message1.equals(other.getMessage1())));
   __equalsCalc = null;
   return _equals;
 }
  /**
   * static method testing jdbc framework with multiple updates and intentional sql exceptions that
   * are trapped in appropriate exception handling blocks
   */
  public static void testMultipleUpdatesAndTransWithException() {
    ConnectionPool conPool = getConnectionPool();
    SQLExecutor sqlExec = new SQLExecutor(conPool);
    try {
      sqlExec.setAutoCommit(false);
      sqlExec.addParam(new Integer(7));
      sqlExec.runQuery("UPDATE JDBC_TEST SET CODE = 'Z' WHERE TEST_ID = ?");

      sqlExec.addParam(new Integer(6));
      // integrity constraint violation
      sqlExec.runQuery("UPDATE JDBC_TEST SET TEST_ID = NULL WHERE TEST_ID = ?");

      sqlExec.commitTrans();
      System.out.println("transaction committed");
    } catch (DatabaseException e) {
      System.out.println("Error code=" + e.getSQLErrorCode() + ",  SQLState=" + e.getSQLState());
      if (e.isDataIntegrityViolation()) System.out.println("data integrity violation");
      else if (e.isBadSQLGrammar()) System.out.println("bad SQL grammar");
      else if (e.isNonExistentTableOrViewOrCol()) System.out.println("Non existent table or view");
      System.out.println(e.getMessage());
      sqlExec.rollbackTrans();
      System.out.println("transaction rolled back");
    } finally {
      sqlExec.closeConnection();
    }
  }
  /**
   * static method testing jdbc framework with a simple select statement using parameters and the
   * result set's .toString() method
   */
  public static void testSimpleSelectWithParamsAndToString() {
    try {
      driverName = "oracle.jdbc.driver.OracleDriver";
      connURL = "jdbc:oracle:thin:@SNOWMASS:1521:WDEV";
      username = "******";
      password = "******";

      ConnectionPool conPool = new ConnectionPool(1, driverName, connURL, username, password);
      SQLExecutor sqlExec = new SQLExecutor(conPool);
      //            sqlExec.addParam(new Integer(8));
      sqlExec.addParam(8);
      sqlExec.addParam(Date.valueOf("2003-05-10"));
      SQLResults res = sqlExec.runQueryCloseCon("SELECT * FROM UTILITY_STATUS");

      String out = "SQL Results:\n" + res.toString();
      System.out.println(out);
    } catch (DatabaseException e) {
      if (e.isDataIntegrityViolation()) applyDataIntegrityViolationRecovery();
    }
  }
 /**
  * INTERNAL: This method notifies the accessor that a particular sets of writes has completed.
  * This notification can be used for such thing as flushing the batch mechanism
  */
 public void writesCompleted() {
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     if (!session.isConnected()) {
       throw DatabaseException.databaseAccessorNotConnected();
     }
   }
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     session.writesCompleted();
   }
 }
  /**
   * static method testing jdbc framework with a select for update statement (that locks a record)
   * and an update statement that generates a deadlock.
   */
  public static void testDeadlockException() {
    ConnectionPool conPool = getConnectionPool();
    SQLExecutor sqlExec1 = new SQLExecutor(conPool);
    try {
      // lock record with a select for update statement
      sqlExec1.setAutoCommit(false);
      sqlExec1.addParam(new Integer(2));
      sqlExec1.runQuery("SELECT CODE FROM JDBC_TEST WHERE TEST_ID = ? FOR UPDATE");

      System.out.println("Attempting to update a record locked by another connection...");
      SQLExecutor sqlExec2 = new SQLExecutor(getConnectionPool());
      sqlExec2.setTimeoutInSec(5); // timeout if deadlocked
      sqlExec2.addParam(new Integer(2));
      sqlExec2.runQueryCloseCon("UPDATE JDBC_TEST SET CODE = 'X' WHERE TEST_ID = ?");
    } catch (DatabaseException e) {
      System.out.println("Error code=" + e.getSQLErrorCode() + ", " + e.getMessage());
      if (e.isRowlockOrTimedOut()) System.out.println("Rowlock exception!");
    } finally {
      conPool.closeAllConnections();
    }
  }
Beispiel #23
0
  private synchronized void init() throws DatabaseException {
    status = PwmService.STATUS.OPENING;
    LOGGER.debug("opening connection to database " + this.dbConfiguration.getConnectionString());

    connection = openDB(dbConfiguration);
    for (final DatabaseTable table : DatabaseTable.values()) {
      initTable(connection, table, dbConfiguration);
    }

    status = PwmService.STATUS.OPEN;

    try {
      put(
          DatabaseTable.PWM_META,
          KEY_ENGINE_START_PREFIX + instanceID,
          PwmConstants.DEFAULT_DATETIME_FORMAT.format(new java.util.Date()));
    } catch (DatabaseException e) {
      final String errorMsg = "error writing engine start time value: " + e.getMessage();
      throw new DatabaseException(new ErrorInformation(PwmError.ERROR_DB_UNAVAILABLE, errorMsg));
    }
  }
 /**
  * INTERNAL: Commit the transaction on all child sessions. This assumes that the commit of the
  * transaction will not fail because all of the modification has already taken place and no errors
  * would have occurred.
  */
 protected void basicCommitTransaction() throws DatabaseException {
   // Do one last check it make sure that all sessions are still connected.
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     if (!session.isConnected()) {
       throw DatabaseException.databaseAccessorNotConnected();
     }
   }
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     session.commitTransaction();
   }
 }
Beispiel #25
0
  @Override
  public void commit(boolean resume, long header, final CommitCallback callback)
      throws IOException {
    // Acquire a shared lock to prevent concurrent commits after callback has released
    // exclusive lock.
    CommitLock.Shared shared = mCommitLock.acquireShared();

    try {
      mHeaderLatch.acquireShared();
      final int commitNumber = mCommitNumber + 1;
      mHeaderLatch.releaseShared();

      try {
        if (!resume) {
          mPageManager.commitStart(header, I_MANAGER_HEADER);
        }
        if (callback != null) {
          // Invoke the callback to ensure all dirty pages get written.
          callback.prepare(resume, header);
        }
      } catch (DatabaseException e) {
        if (e.isRecoverable()) {
          throw e;
        } else {
          throw closeOnFailure(e);
        }
      }

      try {
        commitHeader(header, commitNumber);
        mPageManager.commitEnd(header, I_MANAGER_HEADER);
      } catch (Throwable e) {
        throw closeOnFailure(e);
      }
    } finally {
      shared.release();
    }
  }
 /**
  * INTERNAL: Build the appropriate field value for the specified set of direct values. The
  * database better be expecting an ARRAY.
  */
 public Object buildFieldValueFromDirectValues(
     Vector directValues, String elementDataTypeName, AbstractSession session)
     throws DatabaseException {
   Object[] fields = Helper.arrayFromVector(directValues);
   try {
     ((DatabaseAccessor) session.getAccessor()).incrementCallCount(session);
     java.sql.Connection connection = ((DatabaseAccessor) session.getAccessor()).getConnection();
     return session.getPlatform().createArray(elementDataTypeName, fields, session, connection);
   } catch (java.sql.SQLException ex) {
     throw DatabaseException.sqlException(ex, session, false);
   } finally {
     ((DatabaseAccessor) session.getAccessor()).decrementCallCount();
   }
 }
 private DatabaseException cleanupStack(DatabaseException e) {
   List<StackTraceElement> kept = new ArrayList<StackTraceElement>();
   for (StackTraceElement elem : e.getStackTrace()) {
     if (elem.getClassName().contains("RandomEvent") || elem.getClassName().contains("DB$1")) {
       kept.add(
           new StackTraceElement(
               "enterprise.solution.Connector$1", "execute", "Connector.java", 28340));
       kept.add(new StackTraceElement("enterprise.solution.Connection$1", "process", null, -1));
       kept.add(
           new StackTraceElement(
               "enterprise.solution.driver.TLTPro", "evaluate", "TLTPro.java", 318));
       kept.add(
           new StackTraceElement("enterprise.solution.driver.TLTProAgain", "execute", null, -1));
       kept.add(
           new StackTraceElement(
               "enterprise.framework.ProcessorManagerServiceImpl", "execute", null, -1));
       kept.add(new StackTraceElement("enterprise.solution.A", "sorry", null, -1));
       continue;
     }
     kept.add(elem);
   }
   e.setStackTrace(kept.toArray(new StackTraceElement[kept.size()]));
   return e;
 }
  /**
   * INTERNAL: Build a row representation from the ADT structure field array. TopLink will then
   * build the object from the row.
   */
  public AbstractRecord buildRowFromStructure(Struct structure) throws DatabaseException {
    Object[] attributes;
    try {
      attributes = structure.getAttributes();
    } catch (java.sql.SQLException exception) {
      throw DatabaseException.sqlException(exception);
    }

    if (attributes != null) {
      for (int i = 0; i < attributes.length; i++) {
        if (attributes[i] instanceof Array) {
          attributes[i] =
              ObjectRelationalDataTypeDescriptor.buildArrayObjectFromArray(attributes[i]);
        } else if (attributes[i] instanceof Struct) {
          attributes[i] =
              ObjectRelationalDataTypeDescriptor.buildArrayObjectFromStruct(attributes[i]);
        }
      }
    }

    return buildNestedRowFromFieldValue(attributes);
  }
 /** INTERNAL: Build array of objects for Array data type. */
 public static Object buildArrayObjectFromArray(Object array) throws DatabaseException {
   Object[] objects = null;
   if (array == null) {
     return array;
   }
   try {
     objects = (Object[]) ((Array) array).getArray();
   } catch (java.sql.SQLException ex) {
     throw DatabaseException.sqlException(ex);
   }
   if (objects == null) {
     return null;
   } else {
     for (int i = 0; i < objects.length; i++) {
       if (objects[i] instanceof Array) {
         objects[i] = buildArrayObjectFromArray(objects[i]);
       }
       if (objects[i] instanceof Struct) {
         objects[i] = buildArrayObjectFromStruct(objects[i]);
       }
     }
   }
   return objects;
 }
 /** INTERNAL: Build array of objects for Struct data type. */
 public static Object buildArrayObjectFromStruct(Object structure) throws DatabaseException {
   Object[] attributes = null;
   if (structure == null) {
     return structure;
   }
   try {
     attributes = ((Struct) structure).getAttributes();
   } catch (java.sql.SQLException exception) {
     throw DatabaseException.sqlException(exception);
   }
   if (attributes == null) {
     return null;
   } else {
     for (int i = 0; i < attributes.length; i++) {
       if (attributes[i] instanceof Array) {
         attributes[i] = buildArrayObjectFromArray(attributes[i]);
       }
       if (attributes[i] instanceof Struct) {
         attributes[i] = buildArrayObjectFromStruct(attributes[i]);
       }
     }
   }
   return attributes;
 }