OAKLAND (CBS SF) – A student at Oakland High School appeared in juvenile court Wednesday to answer to four felony charges stemming from the accidental discharge of a gun he allegedly brought to school on Friday, a district attorney’s spokeswoman said.

The student’s name has not been released because he is not yet 18 years old. The charges include gun possession and the discharge of a firearm, Alameda County District Attorney’s Office spokeswoman Teresa Drenick said.

READ MORE: Santa Clara County Mounts Effort to Boost Vaccination Rate to Reach Herd Immunity

Students were in class during the last period around 3 p.m. when the teacher heard a loud noise that she thought was a firecracker, Oakland Unified School District spokesman Troy Flint said.

The 10th-grade student approached the teacher, pleading with her not to call anyone to report the noise, fearful that he would get in trouble or even go to jail, Flint said.

At that point, Flint said, it became clear to the teacher that a gun had been fired.

No one was injured in the shooting, but the bullet ricocheted off a partition in the classroom and came close to hitting another student in the leg, witnesses told district officials, according to Flint.

The student remained in the classroom, agitated, while the teacher tried to calm him down, Flint said.

READ MORE: San Francisco Nightlife: Not Quite Back to Normal But Getting There

She had asked a student aide to let the main office know what had happened, but she did not want to try and call herself, as the student was armed and upset, Flint said.

But the aide, who was in the classroom, did not make the call, Flint said. When the last bell rang, all the students, including the shooter, left the classroom.

The teacher contacted school administrators, who called school district police. Police found the student outside of the campus and took him into custody.

The gun was not recovered and the student was taken to juvenile hall.

The parents of Oakland High School students were contacted to alert them to the incident.

MORE NEWS: California Dodges Outages During Heat Wave But EV Owners Push Grid Capacity

(Copyright 2012 by CBS San Francisco and Bay City News Service. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)