コード例 #1
0
  public void insertAtividade(Atividade atividade) throws SQLException {
    sql =
        "INSERT INTO atividade (NOME, DESCRICAO, USER_MODIF, AUTOR, STATUS)" + "VALUES(?,?,?,?,?)";

    if (!FabricaConexoes.verificaConexao()) FabricaConexoes.getConexao();
    stm = FabricaConexoes.returnStatement(sql);
    stm.setString(1, atividade.getNome());
    stm.setString(2, atividade.getDescricao());

    stm.setInt(3, atividade.getUserModif());
    stm.setInt(4, atividade.getAutor());
    stm.setInt(5, atividade.getStatus());

    stm.execute();

    stm.close();
    FabricaConexoes.closeConnection();
  }
コード例 #2
0
  public void updateAtividade(Atividade atividade) throws SQLException {
    sql =
        "UPDATE atividade SET nome = ?, descricao = ?, user_modif = ?, status = ? WHERE idatividade = ? ";

    if (!FabricaConexoes.verificaConexao()) FabricaConexoes.getConexao();
    stm = FabricaConexoes.returnStatement(sql);

    stm.setString(1, atividade.getNome());
    stm.setString(2, atividade.getDescricao());

    stm.setInt(3, atividade.getUserModif());
    stm.setInt(4, atividade.getStatus());

    stm.setInt(5, atividade.getId());
    stm.execute();
    stm.close();
    FabricaConexoes.closeConnection();
  }
コード例 #3
0
  public void deleteAtividade(Atividade atividade) throws SQLException {
    sql = "DELETE FROM atividade WHERE idatividade = ?";

    if (!FabricaConexoes.verificaConexao()) FabricaConexoes.getConexao();
    stm = FabricaConexoes.returnStatement(sql);

    stm.setInt(1, atividade.getId());

    stm.execute();
    stm.close();
    FabricaConexoes.closeConnection();
  }
コード例 #4
0
  public Atividade getAtividade(Atividade Atividade) throws SQLException, NullPointerException {
    sql = "SELECT * FROM ATIVIDADE WHERE nome = ?";

    if (!FabricaConexoes.verificaConexao()) FabricaConexoes.getConexao();
    stm = FabricaConexoes.returnStatement(sql);
    stm.setString(1, Atividade.getNome());
    rs = stm.executeQuery();
    atividade = new Atividade();
    rs.next();
    atividade.setId(rs.getInt("idatividade"));
    atividade.setNome(rs.getString("nome"));
    atividade.setDescricao(rs.getString("descricao"));

    atividade.setUserModif(rs.getInt("User_Modif"));
    atividade.setAutor(rs.getInt("autor"));
    atividade.setStatus(rs.getInt("status"));

    rs.close();
    stm.close();
    FabricaConexoes.closeConnection();
    return atividade;
  }
コード例 #5
0
  public ArrayList<Atividade> getAll() throws SQLException {
    sql = "SELECT * FROM ATIVIDADE";

    if (!FabricaConexoes.verificaConexao()) FabricaConexoes.getConexao();
    stm = FabricaConexoes.returnStatement(sql);
    rs = stm.executeQuery();

    list = new ArrayList<Atividade>();

    while (rs.next()) {
      atividade = new Atividade();
      atividade.setId(rs.getInt("idatividade"));
      atividade.setNome(rs.getString("nome"));
      atividade.setDescricao(rs.getString("descricao"));

      atividade.setUserModif(rs.getInt("User_Modif"));
      atividade.setAutor(rs.getInt("autor"));
      atividade.setStatus(rs.getInt("status"));

      list.add(atividade);
    }
    FabricaConexoes.closeConnection();
    return list;
  }