Пример #1
0
  @Override
  public void insertProject(Project project) {
    try {
      cmdString = "insert into projects (id, title, home, views) values (?, ?, ?, ?)";
      PreparedStatement s = db.prepareStatement(cmdString);

      s.setString(1, project.getID());
      s.setString(2, project.getTitle());
      s.setString(3, project.getHomeID());
      s.setInt(4, project.getViewCount());

      s.executeUpdate();
    } catch (Exception e) {
      processSQLError(e);
    }
  }
Пример #2
0
  @Override
  public String updateProject(Project project) {

    try {
      cmdString = "update projects set title = ?, home = ?, views = ? where id = ?";
      PreparedStatement s = db.prepareStatement(cmdString);

      s.setString(1, project.getTitle());
      s.setString(2, project.getHomeID());
      s.setInt(3, project.getViewCount());
      s.setString(4, project.getID());

      s.executeUpdate();
    } catch (Exception e) {
      processSQLError(e);
    }
    return null;
  }