A Long Island private investigator was charged Wednesday with paying off an NYPD cop to illegally get information on witnesses from a confidential federal crime database.

Private eye Joseph Dwyer, 46, of Shoreham, who worked for court-appointed defense lawyers in Manhattan federal court, allegedly bribed NYPD Sgt. Ronald Buell, 48, of Kings Park, who retired in February, more than a dozen times for information.

Dwyer worked for Investigative Resource Group of Shoreham, where he was treasurer and his wife was president, and paid Buell $9,000 from 2011 to 2013, the Manhattan federal court complaint said. Buell allegedly accessed data 15 times for information on witnesses in 11 criminal cases in which Dwyer was working as a defense investigator.

"Investigators assisting criminal defendants can -- and should -- do many things to serve their clients, but bribing law enforcement officials for confidential data is not one of them," said U.S. Attorney Preet Bharara in a statement.

Attorneys for Dwyer, himself an ex-cop, and Buell, who retired from the NYPD in February, had no immediate comment on the charges.

The government said it was tipped off to the case in 2013 when Dwyer questioned two eyewitnesses in a homicide case whose names had been kept confidential, and a records check showed that Buell had queried the criminal database about one of the two.

Prosecutors also said that Dwyer -- who was paid taxpayer money for services to poor defendants -- submitted $95-an-hour invoices for "purported investigative work" developing information on witnesses that he had actually gotten by bribing Buell.

Investigative Resource Group billed the federal government for more than $500,000 for services performed by Dwyer between 2011 and 2013, the criminal complaint said.

Dwyer faces up to 45 years in prison. Buell faces up to 25 years in prison. Both men were scheduled to appear in court Wednesday afternoon.