At least 20 others were injured after the attack in Hanzhong city in Shaanxi province, the agency reported, citing local authorities.
China has been shaken by a spate of attacks on schools in recent weeks.
In March, a man stabbed to death eight pupils at a school in Fujian province, and several similar attacks followed.
Worth of stories