You probably need to distinguish between coffee and caffeine.
Caffeine is a chemical compound that is a central nervous system stimulant. It is basically just bitter.
But coffee contains a load of other compounds that create the coffee taste.
Those that affect the human stomach most are tannins, acids and bitters that stimulate the secretion of stomach acids which - in case of a sensitive or already damaged stomach lining - can cause discomfort and pain. The content of those in the beans is greatly influenced by the roasting process (hot and fast typically worse than low and slow, darker roasts more than light ones), type of beans and the brewing process. 1
The easiest answer for a caffeine fix would actually be caffeine - without the accompanying coffee. You should get the powder at your local pharmacy.
But where's the fun in that? So drink lighter roasts or go for a shorter extraction time - Espresso vs. Cowboy coffee are two extreme examples.
1 (Source: Deutscher Kaffeeverband)