Beispiel #1
0
  public void ejbStore() {
    if (!modified) return;

    RunEntityPK pk = (RunEntityPK) entityContext.getPrimaryKey();
    try {
      Connection connection = Util.getInstance().getConnection();
      try {
        PreparedStatement statement =
            connection.prepareStatement(
                "UPDATE Run SET UolId=?, Name=?, Starttime=? WHERE RunId=?");
        try {
          statement.setInt(1, runDto.getUolId());
          statement.setString(2, runDto.getTitle());
          statement.setTimestamp(3, new Timestamp(runDto.getStarttime().getTimeInMillis()));
          statement.setInt(4, pk.runId);
          if (statement.executeUpdate() != 1) {
            throw new EJBException("Could not update " + pk);
          }
        } finally {
          statement.close();
        }
      } finally {
        connection.close();
      }
    } catch (Exception ex) {
      throw new EJBException(ex);
    }
  }
Beispiel #2
0
  /** @see javax.ejb.EntityBean#ejbLoad() */
  public void ejbLoad() {
    makeConnection();
    Integer pk = (Integer) context.getPrimaryKey();
    PreparedStatement ps = null;
    try {
      ps =
          conn.prepareStatement(
              "select umsid,name,comm,pid,sid,id,ts " + "from u_marker_sets where umsid = ?");
      ps.setInt(1, pk.intValue());
      ResultSet rs = ps.executeQuery();

      if (rs.next()) {
        umsid = rs.getInt("umsid");
        name = rs.getString("name");
        comm = rs.getString("comm");
        sid = rs.getInt("sid");
        pid = rs.getInt("pid");
        id = rs.getInt("id");
        ts = rs.getDate("ts");
        dirty = false;
      } else throw new EJBException("UMarkerSetBean#ejbLoad: Error loading UMarker_set");
    } catch (Exception e) {
      throw new EJBException(e);
    } finally {
      releaseConnection();
    }
  }
Beispiel #3
0
  /** Loads the fields of the RunEntity object with data from the database. */
  public void ejbLoad() {
    RunEntityPK pk = (RunEntityPK) entityContext.getPrimaryKey();
    try {
      Connection connection = Util.getInstance().getConnection();
      try {
        PreparedStatement statement =
            connection.prepareStatement("SELECT UolId, Name, Starttime FROM Run WHERE (RunId = ?)");
        try {
          statement.setInt(1, pk.runId);
          ResultSet resultSet = statement.executeQuery();

          if (!resultSet.next()) {
            throw new EJBException("RunEntity not found: " + pk);
          }
          Calendar timestamp = Calendar.getInstance();
          timestamp.setTimeInMillis(resultSet.getTimestamp(3).getTime());
          runDto = new RunDto(pk.runId, resultSet.getInt(1), resultSet.getString(2), timestamp);
          modified = false;
        } finally {
          statement.close();
        }
      } finally {
        connection.close();
      }
    } catch (Exception e) {
      throw new EJBException(pk + " failed to load", e);
    }
  }
  public void ejbStore() {
    System.out.print("ItemBean ejbStore");
    ItemLocal item = (ItemLocal) context.getEJBLocalObject();

    System.out.println("Item price less than $100 : " + item.getId());
    System.out.println("Modifying its price to $200...");
    item.modifyPrice(200.00);
  }
Beispiel #5
0
  /**
   * Removes the run from the database.
   *
   * @throws RemoveException when there is an error removing the run from the database
   */
  public void ejbRemove() throws RemoveException {
    RunEntityPK pk = (RunEntityPK) entityContext.getPrimaryKey();

    try {
      Connection connection = Util.getInstance().getConnection();
      try {
        PreparedStatement statement =
            connection.prepareStatement("DELETE FROM Run WHERE (RunId = ?)");
        try {
          statement.setInt(1, pk.runId);

          if (statement.executeUpdate() == 0) {
            throw new RemoveException("Could not delete " + pk);
          }
        } finally {
          statement.close();
        }
      } finally {
        connection.close();
      }
    } catch (Exception ex) {
      throw new EJBException(ex);
    }
  }
Beispiel #6
0
 /** @ejb.interface-method */
 public Collection getSomeBsDeclaredSQL() throws FinderException {
   return ejbSelectSomeBsDeclaredSQL((ALocal) ctx.getEJBLocalObject());
 }
Beispiel #7
0
 public CommonRemote testPassByRef7() {
   return (CommonRemote) ec_.getEJBObject();
 }