correction and positive reinforcement.
keep him on a lead. when he goes up to someone and sniffs, pull him and firmly say NO!. when he leaves the person alone say GOOOD BOY!
and it is normal for a breed like a german shepherd to be curious about people and dogs that approach you. after all look at what they are used for. and i agree get him/her to sit and german shepherds are very obidient so it should listen.i found it easy to point my finger at my dog and say stop so they know i am not happy.
once your dog finds out how to know when you are or arnt happy with them they will change trust me. when ever you see a dog or person approaching then just try and occupy him and when he ignors the dog/person reward him.
Take him to dog training classes. What he is doing is perfectly for a dog.If you want to change his behaviour he will need to be taught and you will need to learn how to deal with this.
The command leave it can be useful. You could be walking and he sees a dog and gets excited. You say leave it, tug on the leash and continue walking and drag him along. When he stops paying attention, praise him. Bring treats and get and leash with a choke chain. These are very good when dealing with difficult dogs if used right. If you are going to pass the dog, cross the street. If you choose not to cross the street, have him sit until he calms down or have him stand and continue to wlk once he's calm. It is good to know if he tries eating something bad for him on the floor or at a dog park. It can stop him from chewing and many other things you want him to not do. To train him to do this, just keep saying it (no works to) and if he is not a leach, tug it once. Say the command sharply and only once.
Eventually he will learn.