Esempio n. 1
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;
  }
Esempio n. 2
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;
  }