They said the suspect, a 21-year-old man, was detained at the school shortly afterwards without resistance. Students remain in the classroom during a police search of the building. They were removed at lunchtime when investigators determined there were no other offenders on the premises.
Prosecutor Oliver Constian said the injured woman was taken to hospital and her life was still in danger.
Investigations so far indicate that “a certain psychological nature may have contributed to this attack”, he added. He said investigators would work to determine if the suspect knew the victim. There was no immediate word about a possible motive.
According to the German news agency DPA, about 200 students were at the school and the final exams were scheduled. It was not immediately clear how many teachers and other staff were on campus at the time.