U.S. stocks rose on Wednesday as investors bought financial and technology shares ahead of earnings from bellwethers Intel Corp and JPMorgan Chase & Co later this week.

A brokerage upgrade of drugmaker Merck & Co and an upbeat outlook from Kraft Foods Inc gave a boost to the healthcare and consumer sectors.

JPMorgan shares, up 1.8 percent to $44.26, led gains in the KBW bank index <.BKX>, while chip maker Advance Micro Devices jumped 5.3 percent to $9.11 after falling five straight sessions.

Intel shares rose 1.5 percent to $20.92 and a semiconductor index <.SOXX> gained 1.2 percent.

Heading into Intel and JPMorgan earnings, I think there was a sense things have sold off enough and buyers have felt more comfortable buying into semiconductors and financials, said Michael James, senior trader at Wedbush Morgan in Los Angeles.

The Dow Jones industrial average <.DJI> gained 53.74 points, or 0.51 percent, to 10,681.00. The Standard & Poor's 500 Index <.SPX> rose 9.05 points, or 0.80 percent, to 1,145.27. The Nasdaq Composite Index <.IXIC> added 24.85 points, or 1.09 percent, to 2,307.16.

Wall Street, which had its worst session so far this year on Tuesday, opened lower, weighed down by resource shares.

Intel is scheduled to post quarterly results on Thursday and JPMorgan on Friday.

The biggest boost to the Dow came from Merck shares, up 4.4 percent to $39.21 after Credit Suisse upgraded the stock.

Kraft raised its 2009 earnings outlook, sending shares up 0.4 percent to $29.40.

Chocolate maker Hershey Co was still mulling a potential bid for Cadbury but has not decided whether it will proceed with a formal offer, a source familiar with the situation said on Wednesday.

Hershey's shares fell 2.6 percent to $36.75. Kraft is also attempting to buy Cadbury.

Google Inc's shares fell 0.9 percent to $582.03 after the Internet search giant said it may shut its China operations over censorship and hacking. For details see

Shares of rival Chinese search engine Baidu Inc jumped 13 percent to $436.62 and led percentage gains on the Nasdaq 100 <.NDX>.

Crude oil prices slipped 0.4 percent to $80.45 per barrel, and Chevron Corp was the biggest drag on the Dow, falling 0.9 percent to $79.71.

The heads of Wall Street's biggest banks defended the lucrative pay practices and size of their businesses before a commission investigating the 2008 financial crisis.

I think the rally (in financial shares) is more a function of gaining back yesterday's losses than what was going on in Washington, Wedbush Morgan's James said.

The Federal Reserve said in its Beige Book that while economic activity was at a low level, conditions have improved modestly further, and those improvements are broader geographically than in the last report..

(Editing by Kenneth Barry)