Swatting them or punishing them is the slow, painful way for both the pet and the owner.
If you want to get results with potty training, it takes some serious commitment. Praise for the desired action, every time, is the most effective way.
I have had plenty of dogs, but my latest is a blast!
He is a Jack Russell terrier that we rescued from an abusive woman, he was headshy and terrified of punishment. He still cowers down when I scold him, although I never ever hit him. Now he is totally over the head shy bit, I can pound on him in fun and he doesn't flinch

He is crazy fun, push his buttons, sit on the couch, pick your feet up off the floor, and let the races begin!
I have trained him to run right up me into my arms
