@Override public boolean delete(StudentEntity entity) { boolean isDelete = false; try { PreparedStatement statement = connection.prepareStatement("DELETE FROM StudentEntity WHERE id = ?"); statement.setInt(1, entity.getId_student()); int result = statement.executeUpdate(); statement.close(); isDelete = true; } catch (SQLException e) { System.out.println("Не вірний SQL запит на видалення"); e.printStackTrace(); } return isDelete; }
@Override public boolean update(StudentEntity entity) { boolean isUpdated = false; try { PreparedStatement statement = connection.prepareStatement( "UPDATE StudentEntity SET name = ?, surname = ? WHERE id = ?"); statement.setString(1, entity.getName()); statement.setString(2, entity.getSurname()); statement.setInt(3, entity.getId_student()); int result = statement.executeUpdate(); statement.close(); isUpdated = true; } catch (SQLException e) { System.out.println("Не вірний SQL запит на видалення"); e.printStackTrace(); } return isUpdated; }