Downtown SJC is pretty clean and nice, but it drops dead on the weekends. If you're there, go find La Victoria near the college. They have awesome burritos. Near there is a nice area with several restaurants and bars. A good variety.
In SFO, Battery Park is safe because it is a tourist area. Lots of homeless, druggies, hippies, and weirdos (redundant?), but overall a safe area. I've walked all over SFO and never saw a really bad area. You'll need a car to go up there from SJC, unless you want to take public transportation. Once there, you'll be close to Fisherman's Wharf and all that entails. I do recommend going to the Ferry Terminal Building. It is full of specialty shops, restaurants, etc. Upscale, but you can still eat cheap. Free samples for the win! During the week, there is a farmer's market outside and often several food tents.