Stocks rose on Wednesday, shrugging off earlier losses, after Kraft raised its outlook and a brokerage upgraded Merck & Co. in welcome signs about future earnings.

Major indexes had temporarily fallen after a government report showed crude oil stockpiles rose more than expected, a bearish sign for demand in the world's largest energy consumer.

The biggest boost to the Dow came from Merck, the second-largest U.S. drug company. Its shares were up 4.1 percent to $39.07 after Credit Suisse upgraded the stock , saying the pharmaceutical giant's product pipeline should bring upside, with improved visibility over the next 6-24 months.

The Dow Jones industrial average <.DJI> rose 54.87 points, or 0.52 percent, to 10,682.28. The Standard & Poor's 500 Index <.SPX> rose 7.61 points, or 0.67 percent, to 1,143.83. The Nasdaq Composite Index <.IXIC> added 16.56 points, or 0.73 percent, to 2,299.14.

Also lifting sentiment was Kraft Foods Inc , which raised its 2009 earnings outlook late on Tuesday. The Dow component rose 0.6 percent to $29.47, but upside was limited after a report that Hershey Co might be preparing a solo bid for Britain's Cadbury Plc , which Kraft is also attempting to buy.

The outlook suggests that Kraft should do very well in the upcoming earnings season, said Joe Gordon, managing partner of Gordon Asset Management in Durham, North Carolina.

It shows that they're going to make a lot of money, and that comes as people are concerned about whether companies will grow revenue in the quarter.

Crude oil prices slipped 0.8 percent to $80.13 per barrel, and Chevron Corp was the biggest drag on the Dow, falling 0.8 percent to $79.77.

Google's shares fell after the Internet company said it may shut its Chinese-language website because of cyber attacks from China on human rights activists. Google fell 1.4 percent to $582.03, while shares of rival Chinese search engine Baidu Inc jumped 13 percent to $436.98.

The heads of Wall Street's biggest banks defended the lucrative pay practices and size of their businesses but conceded regulatory changes are needed before a blue-ribbon commission investigating the 2008 financial crisis.

The KBW bank index rose 1.9 percent, a day after investors sold financials on concerns about a potential government levy on banks.

(Editing by Kenneth Barry)