A court in southeastern China sentenced a former doctor to death on Thursday for murdering eight children who were on their way to school, state news agency Xinhua reported.
Zheng Minsheng, 41, attacked the children last month just before school began in Nanping in Fujian province.
He admitted to "intentionally killing" the children, at a trial which lasted for four hours, Xinhua said.
"I'm willing to shoulder responsibility for what I've done," the report quoted him as saying.
Prosecutors played 15 video clips of Zheng stabbing children with a knife, it added.
"Zheng, appearing agitated, repeatedly told the court he had been turned down by a girl and suffered unfair treatment from the girl's wealthy family, which prompted him to carry out the attack," Xinhua said.
"Prosecutors said Zheng, who is not married, had been unsuccessful in relations with women, his family and in his career, so he felt life was meaningless," it added. "Zheng had no history of mental illness, according to police."
Five children survived the attack, one of whom is still in intensive care, Xinhua said.
There have been a series of stabbings at Chinese schools and universities in recent years.
In 2008, a student stabbed to death a law professor in class at an elite Beijing law school after he suspected the professor of having an affair with his girlfriend.