Chinese officials say a chemical factory has illegally discharged waste water into a river in southern China , affecting the drinking supply of about 40,000 people .