SAN FRANCISCO -- Matt Cain stood in the on-deck circle preparing to bat during the middle of the game when a fan hollered to let him know he had given up all of one hit.
Cain knew he was cruising along, but pushed it from his mind.
That two-out double in the second by Mark Reynolds was all the Diamondbacks could manage against Cain, who pitched his second one-hitter in the San Francisco Giants' 5-0 victory over Arizona on Friday night.
"It felt good from the beginning. I just tried to keep doing that and tried not to think a lot," Cain said. "I was definitely able to locate both sides of the plate."
Cain has pitched back-to-back complete games, but he tossed eight outstanding innings and still lost 1-0 at Oakland last Saturday on an unearned run.
"You try to take what happened in the last start and get better from it," he said.
Manager Bruce Bochy never even had to warm up a reliever.
Pablo Sandoval hit a solo home run leading off the eighth, ending a 124 at-bat homerless drought dating to his last drive April 21 at San Diego. Sandoval also had a sacrifice fly and an RBI single, giving him a season-best three RBIs.
Sandoval told Cain before the game it was time the free-swinging slugger start contributing home runs in Cain's start like he did in a breakout 2009 season.
Yes, he all but called his shot.
"I'm happy," Sandoval said. "He throws the ball well and it's one of those games you want to help a little more."
Cain (3-4) struck out a season-high nine to end a three-start losing streak. He didn't walk a batter for the first time since his first start of the year.
The pitcher received a rousing standing ovation when he came up to bat in the eighth -- meaning he was staying in to try to finish the job. He did just that, ending the 122-pitch performance in 2 hours, 18 minutes.
"It doesn't get much more dominant than that," said D-backs manager A.J. Hinch, whose team has lost five straight.
Cain also pitched a one-hitter on May 21, 2006, at Oakland. This was his 10th career complete game and third shutout, first since July 24, 2008, against Washington. He has a 1.81 ERA in May.
Reynolds was the only Arizona baserunner to get to second against Cain -- the hit carried more than right fielder Nate Schierholtz said he expected and came off the wall. Reynolds was hit by a pitch in the fifth, the lone other time the D-backs reached base.
"It's one of the better nights he's probably ever had," Arizona's Conor Jackson said. "I didn't see anything to hit. He was painting on the corners and getting ahead of guys. When you do that, you go through the lineup four times, you're going to be successful."
Freddy Sanchez delivered another RBI with a first-inning single to put San Francisco ahead. The Giants backed Cain with enough offense for a change.
Sanchez also doubled and walked a day after he hit a go-ahead, two-run single in the seventh inning of a 5-4 win over the Washington Nationals. He has reached base in seven of his eight plate appearances.
Arizona starter Edwin Jackson (3-6) threw three wild pitches -- two in the first inning -- marking the fifth time a Diamondbacks pitcher has done so.
Jackson struck out seven and walked five in seven innings. He had won his last two starts on the heels of a four-game losing streak but wasn't as sharp this outing.
Arizona, which took two games from the Giants last week in Phoenix, has its third losing streak of five or more games this year.
San Francisco improved to 5-12 versus the NL West, kicking off an important six-game stretch at home against the division.
The Giants are 4-0 while wearing their "Orange Friday" home jerseys, outscoring opponents 22-5.
Cain threw 83 strikes. ... Arizona INF Tony Abreu, on the 15-day disabled list since Tuesday with a sprained left wrist, was examined by hand specialist Dr. Don Sheridan in Arizona and will still wear a protective splint for a couple of days. He could begin baseball activities when the team returns home. ... Giants LHP reliever Jeremy Affeldt, nursing a tweaked left hamstring since Sunday at Oakland, threw a bullpen session and could be available Saturday. ... San Francisco LF Mark DeRosa received a second cortisone shot Thursday in his injured left wrist to help calm down the nerve inflammation that landed him on the DL. DeRosa likely will begin swinging a bat again in a couple of days and could leave on a rehab assignment as soon as Tuesday. ... Arizona C Miguel Montero, on the 15-day DL since April 11 with a right knee sprain, will rejoin the team Saturday and do some baserunning. He will then head out on a rehab assignment at extended spring training.