Neither is necessarily better.
Barbell overhead almost certainly has more carryover to other lifts involving holding a barbell overhead, such as the olympic lifts, and also strongman events too such as the log. It might also be better for the traps, as you'll probably be using more weight (particularly if you are doing push press).
However, I am quite fond of dumbbell overhead pressing for a more specific shoulder exercise. I think they place a bit less stress on the low back, which can be useful if you are already doing lots of squats and deadlifts. And also, it's easier to press them straight up, as you don't have to worry about manoeuvring the bar around your head, and you're also less likely to utilise too much layback.
But you don't have to do only one; you can do both.