Пример #1
0
  public void exluirServico(Servico servico) {
    try {
      Connection con = Conexao.getConexao();
      Statement stmt = con.createStatement();
      String sql = "delete from servico where id=" + servico.getId();
      stmt.executeUpdate(sql);

      con.close();

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }
Пример #2
0
  public boolean alteraServico(Servico servico) {
    boolean resp = false;
    try {
      Connection con = Conexao.getConexao();
      Statement stmt = con.createStatement();
      String sql =
          "update servico set nome='"
              + servico.getNome()
              + "', preco="
              + servico.getPreco()
              + " where id="
              + servico.getId();
      stmt.executeUpdate(sql);
      resp = true;
      con.close();

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return resp;
  }
Пример #3
0
  public boolean salvar(Servico servico) {
    boolean resp = false;
    try {
      Connection con = Conexao.getConexao();
      Statement stmt = con.createStatement();
      String sql =
          "insert into servico values("
              + servico.getId()
              + ",'"
              + servico.getNome()
              + "',"
              + servico.getPreco()
              + ")";
      stmt.executeUpdate(sql);
      con.close();
      resp = true;
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }

    return resp;
  }