Exemple #1
0
  @Override
  public void update(CEP t) {
    try {

      String sql = "UPDATE tb_cep SET" + " cep = ?, endereco = ?, cidade = ? WHERE cep = ?";

      PreparedStatement qb = JDBCUtil.getConnection().prepareStatement(sql);

      qb.setLong(1, t.getCep());
      qb.setString(2, t.getEndereco());
      qb.setString(3, t.getCidade());
      qb.setLong(4, t.getCep());

      qb.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      JDBCUtil.closeConnection();
    }
  }
Exemple #2
0
  @Override
  public void delete(CEP t) {
    try {

      String sql = "DELETE FROM tb_cep WHERE cep = ?";

      PreparedStatement qb = JDBCUtil.getConnection().prepareStatement(sql);
      qb.setLong(1, t.getCep());

      qb.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      JDBCUtil.closeConnection();
    }
  }
Exemple #3
0
  @Override
  public void insert(CEP t) {
    try {

      String sql = "INSERT INTO tb_cep" + "(cep, endereco, cidade)" + "VALUES(?, ?, ?)";

      PreparedStatement qb = JDBCUtil.getConnection().prepareStatement(sql);
      qb.setLong(1, t.getCep());
      qb.setString(2, t.getEndereco());
      qb.setString(3, t.getCidade());

      qb.executeUpdate();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      JDBCUtil.closeConnection();
    }
  }