You can use pain to train, there are just typically better ways. Shock collars do exactly this. Positive reinforcement is the best way but sometimes a shock collar is necessary for immediate intervention.
The truth is that hurting for training should never be a primary means.