Example #1
0
  public void excluir(Rodovia rodovia) throws ClassNotFoundException {

    String sql = "UPDATE RODOVIA" + " SET SITUACAO=0" + " where IDRODOVIA = ?";

    try {
      PreparedStatement stmt = con.prepareStatement(sql);

      stmt.setInt(1, rodovia.getIdRodovia());

      stmt.executeUpdate();
      stmt.close();
      con.close();

      // SQL Server
      /*
      stmt = conS.prepareStatement(sql);

      stmt.setInt(1, rodovia.getIdRodovia());

      stmt.executeUpdate();
      stmt.close();
      conS.close();*/
    } catch (SQLException e) {
      throw new RuntimeException(e + "Erro na Conexão");
    }
  }
Example #2
0
  public void alterar(Rodovia rodovia) throws ClassNotFoundException {

    String sql =
        "update RODOVIA set"
            + " NOME = ?, EXTENSAOKM = ?, CIDADEINICIAL = ?, UFINICIAL = ?, CIDADEFINAL = ?, UFFINAL = ?"
            + " where IDRODOVIA = ?";

    try {
      PreparedStatement stmt = con.prepareStatement(sql);

      stmt.setString(1, rodovia.getNome());
      stmt.setFloat(2, rodovia.getExtensaoKm());
      stmt.setString(3, rodovia.getCidadeInicial());
      stmt.setString(4, rodovia.getUfInicial());
      stmt.setString(5, rodovia.getCidadeFinal());
      stmt.setString(6, rodovia.getUfFinal());
      // stmt.setInt(7, rodovia.getSituacao());
      stmt.setInt(7, rodovia.getIdRodovia());

      stmt.executeUpdate();
      stmt.close();
      con.close();

      // SQO Server
      /*
      stmt = conS.prepareStatement(sql);

      stmt.setString(1, rodovia.getNome());
      stmt.setFloat(2, rodovia.getExtensaoKm());
      stmt.setString(3, rodovia.getCidadeInicial());
      stmt.setString(4, rodovia.getUfInicial());
      stmt.setString(5, rodovia.getCidadeFinal());
      stmt.setString(6, rodovia.getUfFinal());
      stmt.setInt(7, rodovia.getSituacao().charAt(0));
      stmt.setInt(8, rodovia.getIdRodovia());

      stmt.executeUpdate();
      stmt.close();
      conS.close();*/
    } catch (SQLException e) {
      throw new RuntimeException(e + "Erro na Conexão");
    }
  }