public void update(Publicacao pu) throws Exception {

    String sql =
        "UPDATE publicacao SET "
            + "id_anais = ?, "
            + "nome_publicacao = ?, "
            + "tipo_publicacao = ?, "
            + "tema_publicacao = ?, "
            + "area_publicacao = ?, "
            + "resumo_publicacao = ?, "
            + "link_publicacao = ? WHERE id_publicacao = ?";

    Connection conn = ConnectionFactory.getConnection();

    PreparedStatement stmt = conn.prepareStatement(sql);

    if (pu.getAnais() == null) {
      stmt.setString(1, null);
    } else {
      stmt.setInt(1, pu.getAnais().getId());
    }
    stmt.setString(2, pu.getNome());
    stmt.setString(3, pu.getTipo());
    stmt.setString(4, pu.getTema());
    stmt.setString(5, pu.getArea());
    stmt.setString(6, pu.getResumo());
    stmt.setString(7, pu.getLink());
    stmt.setInt(8, pu.getId());
    stmt.execute();
    stmt.close();
  }
  public void delete(Publicacao pu) throws Exception {

    String sql = "DELETE FROM publicacao WHERE id_publicacao = ? ";

    Connection conn = ConnectionFactory.getConnection();

    PreparedStatement stmt = conn.prepareStatement(sql);

    stmt.setInt(1, pu.getId());

    stmt.execute();
    stmt.close();

    conn.close();
  }