Exemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see org.test.dao.impl.IDirayDao#update(org.test.entity.Diray)
   */
  @Override
  public boolean update(Diray d) {
    String sql = "update diray set title=?, centent=?,publishtime=? where id=?";

    try {
      con = DB.getCon();
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, d.getTitle());
      pstmt.setString(2, d.getCentent());
      pstmt.setString(3, d.getPublishtime());
      pstmt.setInt(4, d.getId());
      return pstmt.execute();
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DB.closeAll(con, pstmt, rs);
    }
    return false;
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see org.test.dao.impl.IDirayDao#create(org.test.entity.Diray)
   */
  @Override
  public boolean create(Diray d) {
    String sql = "insert into diray(title,centent,uid,publishtime) values(?,?,?,?)";
    con = DB.getCon();

    try {
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, d.getTitle());
      pstmt.setString(2, d.getCentent());
      pstmt.setInt(3, d.getUsr().getId());
      pstmt.setString(4, d.getPublishtime());
      if (pstmt.executeUpdate() > 0) {
        return true;
      }
    } catch (SQLException e) {

      e.printStackTrace();
    } finally {
      DB.closeAll(con, pstmt, rs);
    }
    return false;
  }