@Override public void update(Student updatedStudent) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement("UPDATE Student SET name=? WHERE id=?"); preparedStatement.setString(1, updatedStudent.getName()); preparedStatement.setInt(2, updatedStudent.getId()); preparedStatement.executeUpdate(); }
@Override public void insert(Student student) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO Student (id,name) VALUES (?,?)"); preparedStatement.setInt(1, student.getId()); preparedStatement.setString(2, student.getName()); preparedStatement.executeUpdate(); }