Exemplo n.º 1
0
  /**
   *
   *
   * <pre>
   * okboard �Է�
   * </pre>
   *
   * @param conn
   * @param article
   * @return result record count
   */
  public int write(Connection conn, Article article) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      pstmt = conn.prepareStatement(QUERY_ADD);
      int idx = 0;
      pstmt.setString(++idx, article.getBbs());
      pstmt.setInt(++idx, article.getSeq());
      pstmt.setInt(++idx, article.getRef());
      pstmt.setString(++idx, String.valueOf(article.getId()));
      pstmt.setString(++idx, article.getWriter());
      pstmt.setString(++idx, article.getSubject());
      pstmt.setString(++idx, article.getContent());
      pstmt.setString(++idx, article.getPassword());
      pstmt.setString(++idx, article.getEmail());
      pstmt.setString(++idx, article.getHomepage());
      pstmt.setString(++idx, article.getIp());
      pstmt.setString(++idx, article.getHtml());
      pstmt.setString(++idx, article.getCcl_id());
      pstmt.executeUpdate();

      if (Integer.valueOf(article.getId()) > 0) {
        new PointDao()
            .log(Integer.valueOf(article.getId()), 2, 10, String.valueOf(article.getSeq()));
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      dbCon.close(null, pstmt, rs);
    }
    return article.getSeq();
  }
Exemplo n.º 2
0
  /**
   * �亯
   *
   * @param conn
   * @param article
   * @return result count
   */
  public int reply(Connection conn, Article article) {

    String query =
        "update okboard set step = step + 1 where bbsid = ? and \"ref\" = ? and step > ?";
    int result = 0;
    PreparedStatement pstmt = null;
    try {
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, article.getBbs());
      pstmt.setInt(2, article.getRef());
      pstmt.setInt(3, article.getStep());
      pstmt.executeUpdate();
      pstmt.close();

      query =
          "insert into okboard (bbsid, seq, \"ref\", step, lev, id, writer, "
              + " subject, content, password, email, homepage, hit, memo, "
              + " wtime, ip, html, ccl_id) values (?,?,?,?,?, ?,?,?,?,old_password(?), "
              + " ?,?,0,0,SYSTIMESTAMP, ?,?,?)";
      pstmt = conn.prepareStatement(query);
      pstmt.setString(1, article.getBbs());
      pstmt.setInt(2, article.getSeq());
      pstmt.setInt(3, article.getRef());
      pstmt.setInt(4, article.getStep() + 1);
      pstmt.setInt(5, article.getLev() + 1);
      pstmt.setString(6, String.valueOf(article.getId()));
      pstmt.setString(7, article.getWriter());
      pstmt.setString(8, article.getSubject());
      pstmt.setString(9, article.getContent());
      pstmt.setString(10, article.getPassword());
      pstmt.setString(11, article.getEmail());
      pstmt.setString(12, article.getHomepage());
      pstmt.setString(13, article.getIp());
      pstmt.setString(14, article.getHtml());
      pstmt.setString(15, article.getCcl_id());
      result = pstmt.executeUpdate();
      if (Integer.valueOf(article.getId()) > 0) {
        new PointDao()
            .log(Integer.valueOf(article.getId()), 2, 10, String.valueOf(article.getSeq()));
      }
    } catch (SQLException e) {
      System.out.println(e.toString());
    } finally {
      dbCon.close(null, pstmt);
    }
    return result;
  }
Exemplo n.º 3
0
  public int write(Article article) throws IOException {
    DbCon dbCon = new DbCon();
    Connection conn = null;
    int result = 0;
    try {
      conn = dbCon.getConnection();

      if ("recruit".equals(article.getBbs())) {
        checkSpam(conn, "recruit", String.valueOf(article.getId()));
      }

      conn.setAutoCommit(false);

      article.setSeq(getSeq(conn));
      article.setRef(getNewRef(conn, article.getBbs()));

      result = write(conn, article);
      conn.commit();
    } catch (SQLException e) {
      try {
        conn.rollback();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      System.out.println("write err: " + e);
    } catch (IOException e) {
      try {
        conn.rollback();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      throw e;
    } finally {
      try {
        conn.setAutoCommit(true);
      } catch (SQLException e) {
        e.printStackTrace();
      }
      dbCon.close(conn, null);
    }

    return result;
  }