I have a 3 year old, so I haven't been through the 5 year old stage yet, but both of my sisters had sons who went through a similar phase you're describing. I think a lot of the issue their sons had was that they were bored. When they were interested in what they were doing, they behaved very well. One of the boys has been tested for ADHD twice, and both times the doctor adamently agreed that he does not have ADHD. He is just an active boy who gets bored if he isn't challenged, and is very bright, so he can get bored easily in situations like a classroom where he isn't allowed to work at a challenging pace.
Another deterrent to a child responding to discipline is if it is applied inconsistently. If they get away with something once, they will try again. I think you just need to be consistent and deal with the whining the same way you deal with other misbehavior. Because your son has had a chance to get these habits ingrained, it will take more effort on your part to break them, but with consistency I know you can do it! Once he realizes his behavior always has negative consequences that he really doesn't like, he'll start to change his behavior.
I can totally relate to the talking, though. My son NEVER stops talking and asking questions. I try to take this in stride, though, because I know he is learning while he talks. He is a very bright kid, and I don't want to discourage him. When I need him to quiet down, I try to distract him. For example, he loves tractors and work trucks, so if he won't stop asking questions while we're in the car, I ask him to watch for those. It usually quiets him down for a few minutes while he looks out the window. At home, I get him something he can do that doesn't require my help - coloring, playing with playdough, etc. Something one of my friends suggested - and she has 6 VERY well behaved children, was to practice being quiet. To prepare her kids to sit quietly through church, she practiced with them at home. She started with 1 minute, and worked up to half an hour or so. She would let them draw or look at books or that kind of thing, but they couldn't talk or move around. Also, she didn't scold them if they started talking or moving. She would just remind them what they were supposed to be doing, or say, "Uh, oh, you're talking!" or something to that effect. She would start with them a few months before they were expected to be able to sit quietly through a church service. Of course, rewarding them with extra praise or a special toy or treat helped. Apparently it worked!
Just remember to reward your son when he is behaving. It is so fun to see my son's face light up when I praise him. My 20 month old daughter is also a reminder to me that praise is important. One of her favorite phrases right now is, "good job!". Whenever someone does what they are asked, she walks around saying it. It always brightens my day when she says, "g'job, Mommy!"