コード例 #1
0
  @Override
  public String updatePage(Project project, Page page) {
    try {
      cmdString = "update pages set title = ?, body = ?, views = ? where id = ?";
      PreparedStatement s = db.prepareStatement(cmdString);

      s.setString(1, page.getTitle());
      s.setString(2, page.getMarkdown());
      s.setInt(3, page.getViewCount());
      s.setString(4, page.getID());
      s.executeUpdate();
    } catch (Exception e) {
      processSQLError(e);
    }

    return null;
  }
コード例 #2
0
  @Override
  public String insertPage(Project project, Page page) {
    if (page == null) {
      return "ERROR: Page cannot be null";
    }
    try {
      cmdString = "insert into pages (id, body, title, views, project) values (?, ?, ?, ?, ?)";
      PreparedStatement s = db.prepareStatement(cmdString);
      s.setString(1, page.getID());
      s.setString(2, page.getMarkdown());
      s.setString(3, page.getTitle());
      s.setInt(4, 0);
      s.setString(5, page.getProjectID());
      // On delete cascade will delete categories and pages involved.
      s.executeUpdate();

    } catch (Exception e) {
      processSQLError(e);
    }

    return null;
  }