BANGOR, Maine — When David J. McDonald was arrested early this year on drug and other charges, he hadn’t been sober since he was 14 years old. The 29-year-old man struggled for nearly 15 years with an opiate addiction that began when he was given painkillers while recovering from orthopedic surgery.

McDonald of Hermon spent three months at the Penobscot County Jail before being accepted into the state’s drug court program in May. Because there was no drug court in Bangor, McDonald traveled to Ellsworth to participate in the Hancock County Adult Drug Treatment Court.

On Wednesday, McDonald and six of his fellow Hancock County drug court participants appeared in a third-floor courtroom where the Penobscot County Adult Drug Treatment Court convened for the first time.

“I chose drug court over jail because I wanted the treatment aspect of it,” McDonald said before court convened. “Plus, I felt the more strict structure of the drug court was better than probation.”

McDonald said having the court in Bangor would be more convenient for him, but he planned to continue his treatment program in Ellsworth.

The session Wednesday was the first time a drug court has convened in Bangor since 2011. The Penobscot County program was shut down that year, and its funding was transferred to the Co-Occurring Disorders Court, also called the mental health court, in Augusta. At the time, officials said the Bangor court was chosen for elimination because its recidivism rate was the worst in the state.

Last year, Rep. Aaron Frey, D-Bangor, and a member of the Appropriations Committee, successfully pushed through an amendment to revitalize the drug court in Bangor at a cost of about $150,000 per year. Stakeholders have been working for the past six months behind the scenes to get the Bangor program up and running.

“This is a positive development,” Penobscot County District Attorney R. Christopher Almy said Wednesday. “The most important thing is that this gives judges here another sentencing option.”

Nonviolent drug offenders may apply for admission to drug courts in York, Androscoggin, Cumberland, Hancock, Washington and, now, Penobscot counties after pleading guilty to charges. The Co-Occurring Disorder Court and the Veterans Court operate out of the Capital Judicial Center in August but also are considered by the judiciary to be drug treatment courts.

A team that includes a judge, a case manager, a treatment provider, a prosecutor, a defense attorney and a probation officer must agree on each admission and oversee the defendants’ progress. Participants must agree to frequent drug testing and counseling, to regular check-ins with the probation officer, to seek employment and to be honest with the judge and other team members.

Failing a drug test could result in sanctions that could include jail time. It also resets the clock on how long an individual has been sober. Participants usually are given three chances to comply with the rules before being kicked out of the program and sentenced to jail or prison time.

McDonald said he spent 24 hours in the Hancock County Jail last year after he admitted to smoking marijuana and failed a drug test. On Wednesday, he said he’d been sober 26 days rather than eight months when he was forced to stop using drugs because he was incarcerated. If he stays on track, McDonald said he could graduate from the program next year.

The number of people in Maine’s drug courts was unavailable Wednesday. The most recent annual report, dated Feb. 15, to the Legislature’s Judiciary Committee includes data from the calendar year 2015 when 223 people participated in drug courts.

“Due to graduations and expulsions, as of Dec. 31, 2015, there were 134 active participants statewide,” the report said. “The number of participants increased dramatically over the previous year’s count of 80 active participants at year’s end in 2014.”

By the end of 2015, all the courts were at capacity except for Washington County, which had nine participants, the report said. Last year, 49 people graduated and 40 others were expelled for noncompliance with requirements and were ordered to serve a previously agreed upon sentence of incarceration.

Each court has the capacity to treat 30 people. As people from Penobscot County move out of the Hancock County Court to Bangor, the open slots are expected to be filled by residents in that county.

While drug courts are not successful for every participant, they are cheaper than housing people in prisons and jails. The annual report said that for every $1 spent on the adult drug treatment courts in Maine, about $1.87 is saved by the state’s criminal justice system.

Adult drug treatment courts generate measurable cost avoidance to the criminal justice system through reduced recidivism and incarceration, the report said. National research has indicated that if all costs are compiled, including those to potential victims, the average cost savings per drug court participant is $12,218.

An evaluation of Maine’s drug courts covering the years 2011 to 2015 found that the recidivism rate for drug court graduates was 16 percent. It was 32 percent for defendants who applied but were not admitted and 49 percent for those who were expelled.

A 2013 Maine Department of Corrections study found that between 39.6 and 47.1 percent of individuals on probation who were assessed as being in the moderate to high-risk category of reoffending, were arrested within 12 months of their release.

The actual cost of running each drug court is not easily calculated, according to the report. It is not possible for the judiciary to calculate the cost of judges or clerks’ time, which is usually a few hours each week. Defense attorneys are paid through the Indigent Legal Defense Commission, prosecutors are paid through the Maine attorney general’s office, and probation officers are paid through the Department of Corrections. None works full time on drug court cases.

Money allocated by lawmakers goes for the case managers, treatment programs and drug testing through the Office of Substance Abuse in the Department of Health and Human Services. The cost before money was allocated for the Bangor Court was about $1.123 million per year.

As far as McDonald — whose addiction progressed over the years from pain pills to heroin — is concerned, it is money well spent.

“I’ve always wanted to get clean, but I’ve never given myself the time to get mentally strong enough to do it,” he said. “Drug court has given me the tools to deal with life sober.”