Package org.apache.stonehenge.stocktrader.dal

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


    if (StockTraderUtility.ORDER_TYPE_SELL.equals(orderType)) {
      // CHECKME holding is the argument
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      order = orderDAO.createOrder(userID, holding.getQuoteID(),
          StockTraderUtility.ORDER_TYPE_SELL, holding.getQuantity(),
          holdingID);

    } else if (StockTraderUtility.ORDER_TYPE_SELL_ENHANCED
        .equals(orderType)) {
      holding = orderDAO.getHolding(holdingID);
      if (holding == null) {
        throw new DAOException("No holding entry found for HoldingID<"
            + holdingID + ">");
      }
      if (quantity > holding.getQuantity()) {
        order = orderDAO.createOrder(userID, holding.getQuoteID(),
            StockTraderUtility.ORDER_TYPE_SELL, holding
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) {
          try {
            insertHoldingStat.close();
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 {
          updateHoldingStat.close();
        } catch (Exception e) {
View Full Code Here

      deleteHoldingStat = sqlConnection.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 {
          deleteHoldingStat.close();
        } catch (SQLException e) {
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 {
          selectHoldingStat.close();
        } catch (SQLException e) {
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();
        } catch (Exception e) {
View Full Code Here

      closeOrderStat.setBigDecimal(3, order.getPrice());
      closeOrderStat.setInt(4, order.getOrderID());
      closeOrderStat.executeUpdate();

    } catch (SQLException e) {
      throw new DAOException("", e);
    } finally {
      if (closeOrderStat != null) {
        try {
          closeOrderStat.close();
        } catch (Exception e) {
View Full Code Here

            logger.debug("", e);
          }
        }
      }
    } catch (SQLException e) {
      throw new DAOException("", e);
    } finally {
      if (insertOrder != null) {
        try {
          insertOrder.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

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.