A man is accused of shooting at a western New York deputy's patrol car while he was making a traffic stop.

The Genesee County Sheriff's Office says 55-year-old David O'Connor was arrested Monday and charged with attempted aggravated murder of a police officer, reckless endangerment and criminal mischief.

Authorities say the deputy had just pulled over a driver in Byron and was sitting in his cruiser when both of his rear side windows shattered. Officers found O'Connor alone in a room in a nearby hotel with a .22-caliber rifle.

Investigators say O'Connor admitted to the shooting.

O'Connor is being held in the county jail in lieu of $25,000 bail.

It's unclear if he has an attorney who could comment on the charges.