The Dow Jones Industrial Average struggled to hold onto gains Tuesday as Apple Inc. (NASDAQ:AAPL) fell nearly 2 percent, a day after the iPhone maker kicked off its five-day annual Worldwide Developers Conference. Reuters/Brendan McDermid

U.S. stocks traded mildly higher Tuesday, trying to snap three straight days of declines as investors weighed a trio of strong U.S. economic data on job openings, small business confidence and inventories. The Dow Jones Industrial Average turned negative for the year a day earlier, driven by losses in the technology sector.

Tuesday’s gains were led by the energy sector, while tech was the largest decliner.

The Dow (INDEXDJX:.DJI) added 6.44 points, or 0.04 percent, to 17,772.99. The Standard & Poor’s 500 index (INDEXNASDAQ:.IXIC) rose 1.14 points, or 0.06 percent, to 2,080.43. However, the Nasdaq composite (INDEXSP:.INX) lost 22.30 points, or 0.43 percent, to 4,999.96.

Dow component Apple Inc. (NASDAQ:AAPL) was the biggest laggard Tuesday, shedding nearly 2 percent a day after the iPhone maker kicked off its five-day annual Worldwide Developers Conference. The major headline announcement was the launch of Apple Music, a 24/7 streaming music service that will compete with the likes of Spotify and help build a "moat around the all-important iTunes franchise," Daniel Ives, analyst at FBR Capital Markets, said in a research note.

CEO Tim Cook announced the company would launch its Apple Music service June 30 for $9.99 a month, or $14.99 as a family plan. Apple also unveiled new versions of the iOS and OS X software.

Apple, which has a market value of $730 billion, has seen its shares gain around 35 in that last 12 months. The stock fell 1.7 percent Tuesday to as low as $125.62.

Apple Inc. - Trailing Year | FindTheCompany

The S&P 500 energy sector rose nearly 1 percent, led by 3 percent gains from Noble Energy, Inc. (NYSE:NBL) and EQT Corporation (NYSE:EQT).

Caterpillar Inc. (NYSE:CAT), the world’s largest construction and mining equipment maker, was the biggest gainer in the Dow, up 1.2 percent, while United Technologies Corporation (NYSE:UTX) and Procter & Gamble Co. (NYSE:PG) both rose nearly 1 percent.

The Job Openings and Labor Turnover Survey (JOLTS), which measures job vacancies, showed there were 5.376 million job openings in April, the highest since December 2000, the U.S. Labor Department said Tuesday. The job openings rate was 3.7 percent.

The latest JOLT survey signals the stronger-than-expected gains in employment in May was no fluke. "Labor market conditions are strengthening and wage growth will accelerate further," Paul Ashworth, chief U.S. economist at Capital Economics, said in a research note Tuesday.

Job Opening Rate, Total Nonfarm - 5 Year | FindTheData

Separately, wholesale inventories, or the amount of unsold inventory still in the possession of U.S. wholesalers, rose 0.4 percent in April, beating expectations of a 0.2 percent rise, the Commerce Department said Tuesday.

If wholesale inventories become too elevated, that typically means retailers are purchasing less because demand for the products has decreased. The rise in inventories, which are a key component of gross domestic product changes, suggests inventories will are likely to be a modest boost to growth in the second quarter.

Meanwhile, U.S. small business confidence jumped to a five-month high in May. The Small Business Optimism Index rose 1.4 points to 98.3 last month, the highest since December, the National Federation of Independent Business announced Tuesday.