Package org.apache.stonehenge.stocktrader.dal

Examples of org.apache.stonehenge.stocktrader.dal.DAOException


        } catch (SQLException e) {
          logger.debug("", e);
        }
      }
    } catch (SQLException e) {
      throw new DAOException("", e);
    } finally {
      if (gainers != null) {
        try {
          gainers.close();
        } catch (SQLException e) {
          logger.debug("", e);
        }
      }
    }
    List<CustomQuoteBean> topLosers = new ArrayList<CustomQuoteBean>();
    PreparedStatement losers = null;
    try {
      losers = sqlConnection
          .prepareStatement(SQL_SELECT_MARKETSUMMARY_LOSERS);
      ResultSet rs = losers.executeQuery();

      try {
        for (int i = 0; rs.next() && i < 5; i++) {
          CustomQuoteBean quote = new CustomQuoteBean(
              rs.getString(1), rs.getString(2), rs.getDouble(3),
              rs.getBigDecimal(4), rs.getBigDecimal(5), rs
                  .getBigDecimal(6), rs.getBigDecimal(7), rs
                  .getDouble(8));
          topLosers.add(quote);
        }
      } finally {
        try {
          rs.close();
        } catch (SQLException e) {
          logger.debug("", e);
        }
      }
    } catch (SQLException e) {
      throw new DAOException("", e);
    } finally {
      if (losers != null) {
        try {
          losers.close();
        } catch (SQLException e) {
View Full Code Here


      previousTransactionIsolation = sqlConnection.getTransactionIsolation();
      sqlConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    } catch (SQLException e) {
      e.printStackTrace();
      logger.debug("", e);
      throw new DAOException("Exception was thrown during the start of transaction", e);
    }
  }
View Full Code Here

    try {
      sqlConnection.commit();
      sqlConnection.setAutoCommit(true);
      sqlConnection.setTransactionIsolation(previousTransactionIsolation);
    } catch (SQLException e) {
      throw new DAOException("Exception is thrown during the commit of transaction", e);
    }
  }
View Full Code Here

    try {
      sqlConnection.rollback();
      sqlConnection.setAutoCommit(true);
      sqlConnection.setTransactionIsolation(previousTransactionIsolation);
    } catch (SQLException e) {
      throw new DAOException("Exception is thrown during the rollback of transaction", e);

    }
  }
View Full Code Here

  public void close() throws DAOException {
    try {
      sqlConnection.close();
    } catch (SQLException e) {
      throw new DAOException("", e);
    }
  }
View Full Code Here

        rs.close();
      } catch (Exception e) {
        logger.debug("", e);
      }
    } catch (SQLException e) {
      throw new DAOException(
          "Exception is thrown when selecting the accountID from order entries where order ID :"
              + order.getOrderID(), e);

    } finally {
      if (getAccountIdStat != null) {
        try {
          getAccountIdStat.close();
        } catch (Exception e) {
          logger.debug("", e);
        }
      }
    }

    if (accountId != -1) {
      int holdingId = -1;
      PreparedStatement insertHoldingStat = null;

      try {
        insertHoldingStat = sqlConnection
            .prepareStatement(SQL_INSERT_HOLDING);
        insertHoldingStat.setBigDecimal(1, order.getPrice());
        // C# - insertHolding.setFloat(1, (float) order.getQuantity());
        insertHoldingStat.setDouble(2, order.getQuantity());
        Calendar openDate = (order.getOpenDate() != null) ? order
            .getOpenDate() : Calendar.getInstance();
        insertHoldingStat.setDate(3, StockTraderUtility
            .convertToSqlDate(openDate));
        insertHoldingStat.setInt(4, order.getAccountId());
        insertHoldingStat.setString(5, order.getSymbol());

        ResultSet rs = insertHoldingStat.executeQuery();
        if (rs.next()) {
          holdingId = rs.getInt(1);
        }

        try {
          rs.close();
        } catch (Exception e) {
          logger.debug("", e);
        }
        return holdingId;

      } catch (SQLException e) {
        throw new DAOException(
            "An exception is thrown during an insertion of a holding entry",
            e);

      } finally {
        if (insertHoldingStat != null) {
View Full Code Here

      updateHoldingStat.setDouble(1, quantity);
      updateHoldingStat.setInt(2, holdingId);
      updateHoldingStat.executeUpdate();

    } catch (SQLException e) {
      throw new DAOException(
          "An exception is thrown during an updation of holding entry",
          e);
    } finally {
      if (updateHoldingStat != null) {
        try {
View Full Code Here

          .prepareStatement(SQL_DELETE_HOLDING);
      deleteHoldingStat.setInt(1, holdingId);
      deleteHoldingStat.execute();

    } catch (SQLException e) {
      throw new DAOException(
          "An exception is thrown during deletion of a holding entry",
          e);
    } finally {
      if (deleteHoldingStat != null) {
        try {
View Full Code Here

            logger.debug("", e);
          }
        }
      }
    } catch (SQLException e) {
      throw new DAOException(
          "An Exception is thrown during selecting a holding entry",
          e);
    } finally {
      if (selectHoldingStat != null) {
        try {
View Full Code Here

      updateHoldingStat.setDouble(1, order.getQuantity());
      updateHoldingStat.setInt(2, order.getOrderID());
      updateHoldingStat.executeUpdate();

    } catch (SQLException e) {
      throw new DAOException(
          "An Exception is thrown during updating a holding entry", e);
    } finally {
      if (updateHoldingStat != null) {
        try {
          updateHoldingStat.close();
View Full Code Here

TOP

Related Classes of org.apache.stonehenge.stocktrader.dal.DAOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.