Esempio n. 1
0
  @Override
  public boolean update(Object T) {
    Aanbieding aanbieding = (Aanbieding) T;

    try {
      Connection connection = null;
      connection = GetConnection.getDBConnection();
      if (connection != null) {
        System.out.println("|| Connection ready || ");
      } else {
        System.out.println("|| Connection failed ||");
      }
      PreparedStatement ps =
          connection.prepareStatement(
              "update aanbiedingen set eindtijd = ?, startprijs =?, image =? where id = ?");
      ps.setTimestamp(1, aanbieding.getEindtijd());
      ps.setDouble(2, aanbieding.getStartprijs());
      ps.setBytes(3, aanbieding.getImg());
      ps.setInt(4, aanbieding.getId());
      ResultSet rs = ps.executeQuery();
      rs.close();
      ps.close();
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    GetConnection.closeConnection();
    return true;
  }
Esempio n. 2
0
  @Override
  public void delete(Object T) {
    Aanbieding aanbieding = (Aanbieding) T;
    try {
      Connection connection = null;
      connection = GetConnection.getDBConnection();
      if (connection != null) {
        System.out.println("|| Connection ready || ");
      } else {
        System.out.println("|| Connection failed ||");
      }
      if (aanbieding.getGebruikers_klantnr() == 0) {

        PreparedStatement ps =
            connection.prepareStatement("delete from biedingen where aanbiedingen_id = ?");
        ps.setInt(1, aanbieding.getId());
        ResultSet rs = ps.executeQuery();
        rs.close();
        ps.close();

        PreparedStatement ps2 =
            connection.prepareStatement("delete from aanbiedingen where id = ?");
        ps2.setInt(1, aanbieding.getId());
        ResultSet rs2 = ps2.executeQuery();
        rs2.close();
        ps2.close();

      } else {
        PreparedStatement ps3 =
            connection.prepareStatement(
                "delete from aanbiedingen where id = ? and gebruikers_klantnr =?");
        ps3.setInt(1, aanbieding.getId());
        ps3.setInt(2, aanbieding.getGebruikers_klantnr());
        ResultSet rs3 = ps3.executeQuery();
        rs3.close();
        ps3.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    GetConnection.closeConnection();
  }